Created
April 16, 2019 08:00
-
-
Save PhilmacFLy/f51457dd4dbab47a5c0f3470217124ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> // Ein - und Ausgabeoperationen | |
#include"Rechenoperatoren.h" | |
#include <ctype.h> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
//zahlen und operator | |
int zahl_1,zahl_2,zahl_3; | |
int ergebnis = 0; | |
char operation; | |
bool lweiter = true; | |
char eingabespeicher[10]; | |
string operations; | |
while(lweiter) | |
{ | |
cout<<"Geben Sie die gewuenschte Rechenoperation ein:"<<endl; | |
cout<<"[+]=Addition"<<endl; | |
cout<<"[-]=Subtraktion"<<endl; | |
cout<<"[*]=Multipilkation"<<endl; | |
cout<<"[/]=Division"<<endl; | |
cout<<"[B]=Abbruch"<<endl; | |
cin>>operation; | |
// Auswertung der Eingabe | |
if (operation=='+'||operation=='-'||operation=='*'||operation=='/') | |
{ | |
cout<<"Geben Sie nun die 3 Zahlenwerte ein:"<<endl; | |
bool cont = false; | |
while (!cont) { | |
cout<<"1. Zahl:" << endl; | |
cin>>zahl_1; | |
cont = cin.fail() | |
} | |
cont = false; | |
while (!cont) { | |
cout<<"2. Zahl:" << endl; | |
cin>>zahl_2; | |
cont = cin.fail() | |
} | |
cont = false; | |
while (!cont) { | |
cout<<"3. Zahl:" << endl; | |
cin>>zahl_3; | |
cont = cin.fail() | |
} | |
switch(operation) | |
{ | |
case '+' : | |
ergebnis = Addition(zahl_1, zahl_2, zahl_3); | |
cout << "\n>> " << ergebnis << endl << endl; | |
break; | |
case '-' : | |
ergebnis = Subtraktion(zahl_1, zahl_2, zahl_3); | |
cout << "\n>> " << ergebnis << endl << endl; | |
break; | |
case '*' : | |
ergebnis = Multiplikation(zahl_1, zahl_2, zahl_3); | |
cout << "\n>> " << ergebnis << endl << endl; | |
break; | |
case '/' : | |
ergebnis = Division(zahl_1, zahl_2, zahl_3); | |
cout << "\n>> " << ergebnis << endl << endl; | |
break; | |
} | |
operations = operations + " " + std::to_string(zahl_1); | |
operations = operations + " " + std::to_string(zahl_2); | |
operations = operations + " " + std::to_string(zahl_3); | |
operations = operations + " " + operation; | |
operations = operations + "\n" | |
} | |
else if(operation=='B') | |
{ | |
cout<<"\n Sie haben abgebrochen!!"<<endl; | |
lweiter = false; | |
} | |
else | |
{ | |
cout << "\nUngueltige OperatorenEingabe\n" << "Geben Sie bitte nur + - * / ein\n" <<endl; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment