-
Notifications
You must be signed in to change notification settings - Fork 4
/
task2_simplecalculator.cpp
54 lines (46 loc) · 1.44 KB
/
task2_simplecalculator.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
#include <iostream>
using namespace std;
class simplecalculator
{
public:
float num1, num2;
void setnumbers()
{
cout << "please enter number 1 : " << endl;
cin >> num1;
cout << "please enter number 2 : " << endl;
cin >> num2;
}
public:
void setoperation() {
int operation;
cout << " please select an operation \n enter 1 for addition \n enter 2 for substraction \n enter 3 for multiplication \n enter 4 for division \n ";
cin >> operation;
switch (operation){
case 1 :
cout << " addition of number1 and number2 is : " << endl
<< num1 + num2;
break;
case 2 :
cout << "substraction of number1 and number2 is : " << endl
<< num1 - num2 ;
break ;
case 3 :
cout << " multiplication of number1 and number2 is : " << endl
<< num1 * num2;
break ;
case 4 :
cout << " division of number1 and number2 is : " << endl
<< num1/num2;
break ;
default:cout << " please enter a correct number of operation ." ;
break;
} }
};
int main()
{ cout << " TASK - SIMPLE CALCULATOR " << endl ;
simplecalculator calculation1;
calculation1.setnumbers();
calculation1.setoperation();
return 0;
}