-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
58 lines (56 loc) · 1.36 KB
/
main.cpp
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
51
52
53
54
55
56
57
58
#include <iostream>
using namespace std;
class BasicMath{
public:
int addnum(int x, int y){
return x + y;
}
int subnum(int x, int y){
return x - y;
}
int multnum(int x, int y){
return x * y;
}
int divnum(int x, int y){
return x / y;
}
int modnum(int x, int y){
return x % y;
}
};
int main()
{
char answer;
int x;
int y;
cout << "Pick a number: \n";
cin >> x;
cout << "Pick another number: \n";
cin >> y;
cout << "What math operation would you like to do? \n";
cout << "(A)dd Numbers \n";
cout << "(S)ubtract Numbers \n";
cout << "(M)ultiply Numbers \n";
cout << "(D)ivide Numbers \n";
cout << "(G)et the remainder of Numbers \n";
cin >> answer;
BasicMath bm;
if (answer == 'A'){
cout << bm.addnum(x, y) << endl;
} else if (answer == 'S'){
cout << bm.subnum(x, y) << endl;
} else if (answer == 'M'){
cout << bm.multnum(x, y) << endl;
} else if (answer == 'D'){
if (x < 0 || y < 0){
cout << "Invalid Numbers. \n";
} else {
cout << bm.divnum(x, y) << endl;
}
} else if (answer == 'G'){
cout << bm.modnum(x, y) << endl;
} else {
cout << "Invalid Choice. \n";
}
return 0;
}