Created the calculator.cpp

This commit is contained in:
Mathias Wagner 2023-09-28 08:11:38 +02:00
parent d9f7fdc347
commit f95d13537e
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

51
calculator.cpp Normal file
View File

@ -0,0 +1,51 @@
#include <iostream>
using namespace std;
int number(int current) {
cout << "+ - * oder :?";
string input;
cin >> input;
cout << "Was möchtest du berechnen?";
int num2;
cin >> num2;
if(input == "+") {
return current + num2;
} else if(input == "-") {
return current - num2;
} else if(input == "*") {
return current * num2;
} else if(input == ":") {
return current / num2;
}
}
int main() {
cout << "Was ist die Startzahl?";
int start;
cin >> start;
bool finished = false;
while (!finished) {
start = number(start);
cout << "Möchtest du weiter machen?";
string input;
cin >> input;
if (input == "nein" || input == "Nein") {
finished = true;
}
}
cout << "Dein Ergebnis: " << start;
return 0;
}