-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_calculator.cpp
82 lines (70 loc) · 1.7 KB
/
simple_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
#include <iostream>
using namespace std;
int main()
{
// Simple calculator using "Switch Case" //
int operation;
int sum, difference, product, quotient;
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
cout << "Please choose the operation you want to perform: " << endl;
cout << "1-->Addition 2-->Substraction 3-->Division 4-->Multiplcation" << endl;
cin >> operation;
switch (operation)
{
case 1:
cout << "Addition: " << endl;
cout << "Enter the first number: " << endl;
cin >> a;
cout << "Enter the second number: " << endl;
cin >> b;
sum = a + b;
cout << "The sum of the two numbers is: ";
cout << sum<<endl;
cout<<"Hope this helps!";
break;
case 2:
cout << "Substraction: " << endl;
cout << "Enter the first number: " << endl;
cin >> c;
cout << "Enter the second number: " << endl;
cin >> d;
difference = c - d;
cout << "The difference is: ";
cout << difference<<endl;
cout<<"Hope this helps!";
break;
case 3:
cout << "Division: " << endl;
cout << "Enter the Divident: " << endl;
cin >> e;
cout << "Enter the divisor: " << endl;
cin >> f;
quotient = e / f;
cout << "The quotient is: ";
cout << quotient<<endl;
cout<<"Hope this helps!";
break;
case 4:
cout << "Multiplication: " << endl;
cout << "Enter the first number: " << endl;
cin >> g;
cout << "Enter the second number: " << endl;
cin >> h;
product = g * h;
cout << "The product is: ";
cout << product<<endl;
cout<<"Hope this helps!";
break;
default:
cout << "Invalid operation!! Please try again....." << endl;
break;
}
return 0;
}