-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.cpp
71 lines (59 loc) · 1.43 KB
/
Calculator.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
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
using namespace std;
class Calculator {
private:
int num1;
int num2;
void add() {
cout << "Number 1 + Number 2 = " << num1 + num2;
}
void subtract() {
cout << "Number 1 - Number 2 = " << num1 - num2;
}
void multiply() {
cout << "Number 1 x Number 2 = " << num1 * num2;
}
void divide() {
cout << "Number 1 / Number 2 = " << num1 / num2;
}
void moduluo() {
cout << "Number 1 % Number 2 = " << num1 % num2;
}
public:
void getInputs() {
cout << "Enter number 1: ";
cin >> num1;
cout << "Enter number 2: ";
cin >> num2;
}
void getOperation() {
int operation;
cout << "Enter operation to perform: ";
cin >> operation;
switch (operation) {
case 1:
add();
break;
case 2:
subtract();
break;
case 3:
multiply();
break;
case 4:
divide();
break;
case 5:
moduluo();
break;
default:
cout << "Invalid Operation";
break;
}
}
};
int main() {
Calculator calculator;
calculator.getInputs();
calculator.getOperation();
}