-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathC++ZeroDashZero.cpp
121 lines (102 loc) · 3.38 KB
/
C++ZeroDashZero.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <iostream>
#include <conio.h>
using namespace std;
class Calculator
{
public:
void Font()
{
cout <<"\t\t\t .d8888b. 888 888 888 "<<endl;
cout <<"\t\t\t d88P Y88b 888 888 888 "<<endl;
cout <<"\t\t\t 888 888 888 888 888 "<<endl;
cout <<"\t\t\t 888 8888b. 888 .d8888b 888 888 888 8888b. 888888 .d88b. 888d888 "<<endl;
cout <<"\t\t\t 888 88b 888 d88P 888 888 888 88b 888 d88..88b 888P "<<endl;
cout <<"\t\t\t 888 888 .d888888 888 888 888 888 888 .d888888 888 888 888 888 "<<endl;
cout <<"\t\t\t Y88b d88P 888 888 888 Y88b. Y88b 888 888 888 888 888. d88..88P 888 "<<endl;
cout <<"\t\t\t Y88888Y Y888888 888 Y8888P Y88888 888 Y888888 88888 Y88P 888 "<<endl;
cout <<endl<<endl<<endl<<endl;
}
float Addition(float x, float y)
{
float ans = x + y;
return ans;
}
float Subtraction(float x, float y)
{
float ans = x - y;
return ans;
}
float Multiplication(float x, float y)
{
float ans = x * y;
return ans;
}
float Division(float x, float y)
{
float ans = x / y;
return ans;
}
};
int main()
{
int choice;
float x, y;
Calculator Calc;
Calc.Font();
cout << "Which operation do you want to perform? " << endl;
cout << "\t 1 - Addition " << endl;
cout << "\t 2 - Subtraction " << endl;
cout << "\t 3 - Multiplication " << endl;
cout << "\t 4 - Division " << endl<<endl;
cout << "Choose a number accordingly : " << endl;
cin >> choice;
cout << endl<<endl;
switch(choice)
{
case 1: //Addition
cout << "****ADDITION****" << endl << endl;
cout << "Please enter the first number: " << endl;
cin >> x;
cout << "Please enter the second number: " << endl;
cin >> y;
cout << endl << x << " + " << y << " = ";
cout << Calc.Addition(x, y);
break;
case 2: //Subtraction
cout << "****SUBTRACTION****" << endl << endl;
cout << "Please enter first number: " << endl;
cin >> x;
cout << "Please enter second number: " << endl;
cin >> y;
cout << endl << x << " - " << y << " = ";
cout << Calc.Subtraction(x, y);
break;
case 3: //Multiplication
cout << "****MULTIPLICATION****" << endl << endl;
cout << "Please enter first number: " << endl;
cin >> x;
cout << "Please enter second number: " << endl;
cin >> y;
cout << endl << x << " x " << y << " = ";
cout << Calc.Multiplication(x, y);
break;
case 4: //Division
cout << "****DIVISION****" << endl;
cout << "Please enter first number: " << endl;
cin >> x;
cout << "Please enter second number: " << endl;
cin >> y;
if(y==0)
cout << endl <<"\a Cannot divide a number by zero!" << endl;
else
{
cout << endl << x << " / " << y << " = ";
cout << Calc.Division(x, y);
}
break;
default:
cout << "\a Invalid Choice!";
break;
}
getch();
}