-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculatorv2.cpp
More file actions
48 lines (42 loc) · 1.05 KB
/
Copy pathcalculatorv2.cpp
File metadata and controls
48 lines (42 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
int main(){
double n0 = 0, n1 = 0, o0 = 0;
std::string restart0 = "y";
std::string c0 = "E";
while(restart0 == "y")
{
std::cout << "CalculatorV2-Input the first number!" << '\n';
std::cin >> n0;
std::cout << "what function do wou want to perform? + - * /" << '\n';
std::cin >> c0;
std::cout << "Input the second number" << std::endl;
std::cin >> n1;
if (c0 == "+")
{
o0 = n0 + n1;
std::cout << "the answer is " << o0 << '\n';
}
else if (c0 == "-")
{
o0 = n0 - n1;
std::cout << "the answer is " << o0 << '\n';
}
else if (c0 == "*")
{
o0 = n0 * n1;
std::cout << "the answer is " << o0 << '\n';
}
else if (c0 == "/")
{
o0 = n0 / n1;
std::cout << "the answer is " << o0 << '\n';
}
else
{
std::cout << "ERROR" << '\n';
}
std::cout << "Restart? y/n" << '\n';
std::cin >> restart0;
}
return 0;
}