1#include <iostream>
2
3using namespace std;
4
5int main()
6{
7cout << "Welcome to the Calculator, write :cancel: to cancel the calculator\n";
8 string cancel;
9
10 while(cancel != "cancel")
11 {
12 int number1 = 0;
13 int number2 = 0;
14 string op;
15
16 cout << "please enter your first number!\n";
17
18 cin >> number1;
19
20 cout << "please enter your second number!\n";
21
22 cin >> number2;
23
24 cout << "please enter a operator!\n";
25 cout << "( *, / , + , - )";
26
27 cin >> op;
28
29 if(op == "*")
30 {
31 number1 = number1 * number2;
32 cout << number1;
33 number1 = 0;
34 number2 = 0;
35 }
36
37 if(op == "/")
38 {
39 number1 = number1 / number2;
40 cout << number1;
41 number1 = 0;
42 number2 = 0;
43 }
44
45 if(op == "+")
46 {
47 number1 = number1 + number2;
48 cout << number1;
49 number1 = 0;
50 number2 = 0;
51 }
52
53 if(op == "-")
54 {
55 number1 = number1 - number2;
56 cout << number1;
57 number1 = 0;
58 number2 = 0;
59 }
60
61 cout << "Write cancel to cancel\n";
62 cout << "write continue to resume with the calculator!\n";
63
64 cin >> cancel;
65
66 }
67
68
69}
70//powered by my coding server: https://discord.gg/GUgnYHJV
1#include <iostream>
2
3using namespace std;
4
5int main()
6{
7int num1;
8int num2;
9char op;
10
11 cout << "Enter a number:" << endl;
12 cin >> num1; //takes input
13
14 cout << "Enter another number:" << endl; //prints some prompt
15 cin >> num2;
16
17 cout << "Enter a operator:" << endl; //prints some prompt
18 cin >> op;
19
20 if(op == '+')
21 {
22 cout << "Result = " << num1 + num2 << endl;
23 }else if(op == '-'){
24 cout << "Result = " << num1 - num2 << endl;
25 }else if(op == '*'){
26 cout << "Result = " << num1 * num2 << endl;
27 }else if(op == '/'){
28 cout << "Result = " << num1 / num2 << endl;
29 }
30
31
32}