mirror of
https://inf-git.fh-rosenheim.de/studavrije7683/cplusplus-training.git
synced 2025-04-19 15:59:56 +00:00
35 lines
678 B
C++
35 lines
678 B
C++
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
int main()
|
|
{
|
|
|
|
float z1 = 0, z2 = 0;
|
|
char op = 0;
|
|
cout << "Bitte Ausdruck eingeben: \n";
|
|
cin >> z1 >> op >> z2;
|
|
switch (op)
|
|
{
|
|
case '+':
|
|
cout<< "Ergebnis: "<<(z1+z2)<<endl;
|
|
break;
|
|
case '-':
|
|
cout<< "Ergebnis: "<<(z1-z2)<<endl;
|
|
break;
|
|
case '*':
|
|
cout<< "Ergebnis: "<<(z1*z2)<<endl;
|
|
break;
|
|
case '/':
|
|
if(z2==0)
|
|
cout << "Division durch null!\n";
|
|
else
|
|
cout<< "Ergebnis: "<<(z1/z2)<<endl;
|
|
break;
|
|
default:
|
|
cout << "Es gab einen Fehler in der Anweisung";
|
|
}
|
|
|
|
} |