-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.cpp
100 lines (93 loc) · 1.93 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//Calculator
//By Artin Moghadasi
//@Artin.Projects
#include <iostream>
using namespace std;
void add();
void sub();
void div();
void mul();
int num1,num2;
int main()
{
int UserChoice,round;
char UseOfCalculator;
round=1;
while (1)
{
if(round==1)
cout<<"Welcome to Turing Calculator! \n";
else
cout<<"Welcome back to Turing Calculator! \n";
cout<<"Round: "<<round<<endl;
cout<<"Enter your Choice: \n";
cout<<"1. Addition \n";
cout<<"2. Subtraction \n";
cout<<"3. Division \n";
cout<<"4. Multiplication \n";
cout<<"Userchoice: ";
cin>>UserChoice;
cout<<endl;
switch(UserChoice)
{
case 1:
add();
break;
case 2:
sub();
break;
case 3:
div();
break;
case 4:
mul();
break;
default:
cout<<"Please select valid choice for next time";
break;
}
cout<<endl<<"Do you want to use this calculator again?(y/n) \n";
cin>>UseOfCalculator;
if(UseOfCalculator=='y')
round++;
else
{
cout<<"Thanks!";
exit(0);
}
}
return 0;
}
void add()
{
cout<<"Enter First Number: ";
cin>>num1;
cout<<"Enter Second Number: ";
cin>>num2;
cout<<"The Sum is: "<<num1+num2;
}
void sub()
{
cout<<"Enter First Number: ";
cin>>num1;
cout<<"Enter Second Number: ";
cin>>num2;
cout<<"The Sub is: "<<num1-num2;
}
void div()
{
cout<<"Enter First Number: ";
cin>>num1;
cout<<"Enter Second Number: ";
cin>>num2;
cout<<"The Division is: "<<num1/num2;
}
void mul()
{
cout<<"Enter First Number: ";
cin>>num1;
cout<<"Enter Second Number: ";
cin>>num2;
cout<<"The Multiplication is: "<<num1*num2;
}
//The Program is finished!