Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (34 loc) · 1.33 KB
/
Copy pathmain.cpp
File metadata and controls
50 lines (34 loc) · 1.33 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
49
50
#include <format>
#include <iostream>
int main() {
std::cout << "Calculator has been activated" << std::endl << "Write command 'plus,minus,multiply,divid" <<std::endl;
while (true) {
std::string command;
std::cin >> command;
if (command == "plus") {
std::cout << "Write two more input!" << std::endl;
auto x = 0, y = 0;
std::cin >> x >> y;
std::cout << x << " + " << y << " = " << x+y << std::endl;
} else if (command == "minus") {
std::cout << "Write two more input!" << std::endl;
auto x = 0, y = 0;
std::cin >> x >> y;
std::cout << x << " - " << y << " = " << x-y << std::endl;
} else if (command == "multiply") {
std::cout << "Write two more input!" << std::endl;
auto x = 0, y = 0;
std::cin >> x >> y;
std::cout << x << " x " << y << " = " << x*y << std::endl;
} else if (command == "divid") {
std::cout << "Write two more input!" << std::endl;
auto x = 0, y = 0;
std::cin >> x >> y;
std::cout << x << " : " << y << " = " << x/y << std::endl;
} else if (command == "exit") {
std::cout << "The program is exit!" << std::endl;
break;
}
}
return 0;
}