-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindows_calculator.cpp
More file actions
291 lines (276 loc) · 6.32 KB
/
windows_calculator.cpp
File metadata and controls
291 lines (276 loc) · 6.32 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/*
simple_calculator -- addition , subtraction , multiplication , division.
scintific_calculator -- square , square root , distance , time of free fall in gravity
*/
// I want to edit your program for more efficiency
#include <iostream>
#include <cmath>
// you have to watch video on different between "cmath & math.h"
using namespace std;
class simple
{
protected:
float a, b, c;
public:
simple() {}
void sum(float x, float y)
{
a = x;
b = y;
c = a + b;
}
void sub(float x, float y)
{
a = x;
b = y;
c = a - b;
}
void mul(float x, float y)
{
a = x;
b = y;
c = a * b;
}
void div(float x, float y)
{
a = x;
b = y;
c = a / b;
}
void result()
{
cout << "Ans = " << c;
}
};
class scintific
{
protected:
float a, b, c, d, e;
public:
scintific() {}
void sq(float x)
{
a = x;
c = pow(a, 2);
}
void root(float x)
{
a = x;
c = sqrtf(a);
}
void dis(float x1, float y1, float x2, float y2)
{
c = sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2));
}
void free_falll(float x, float y)
{
a = x;
b = y;
c = sqrtf((2 * a) / b);
}
void out()
{
cout << "Ans = " << c;
}
};
class Hibride : public simple, scintific
{
protected:
public:
Hibride() {}
};
//
//
//
//
int main()
{
int a;
float m, n, o, p;
scintific o1;
simple x;
Hibride o2;
cout << "This is the calculator"
<< endl
<< "Enter 1 for simple calculator\n"
<< "Enter 2 for scintific calculator\n"
<< "Enter 3 for Hibride calculator"
<< endl;
cin >> a;
switch (a)
{
case 1:
int z;
while (z = !0)
{
cout << "Enter 1 for sum\n"
<< "Enter 2 for sub\n"
<< "Enter 3 for mul\n"
<< "Enter 4 for div\n"
<< "Enter 0 for out" << endl;
cin >> z;
if (z == 1)
{
cout << "Enter the number =";
cin >> m >> n;
x.sum(m, n);
}
else if (z == 2)
{
cout << "Enter the number =";
cin >> m >> n;
x.sub(m, n);
}
else if (z == 3)
{
cout << "Enter the number =";
cin >> m >> n;
x.mul(m, n);
}
else if (z == 4)
{
cout << "Enter the number =";
cin >> m >> n;
x.div(m, n);
}
else if (z == 0)
{
break;
}
cout << "\n"
<< endl;
}
break;
case 2:
int Q;
while (Q = !0)
{
cout << "Enter 1 for square\n"
<< "Enter 2 for square root\n"
<< "Enter 3 for distance\n"
<< "Enter 4 for time of free fall\n"
<< "Enter 0 for out" << endl;
cin >> Q;
if (Q == 1)
{
cout << "Enter the number =";
cin >> m;
o1.sq(m);
o1.out();
}
else if (Q == 2)
{
cout << "Enter the number =";
cin >> m;
o1.root(m);
o1.out();
}
else if (Q == 3)
{
cout << "X1,Y1 =";
cin >> m >> n;
cout << "X2,Y2 =";
cin >> o >> p;
o1.dis(m, n, o, p);
o1.out();
}
else if (Q == 4)
{
cout << "Enter hight of object =";
cin >> m;
cout << "Enter constant acceleration =";
cin >> n;
o1.free_falll(m, n);
o1.out();
}
else if (Q == 0)
{
break;
}
cout << "\n"
<< endl;
}
break;
case 3:
int Z;
while (Z = !0)
{
cout << "Enter 1 for sum\n"
<< "Enter 2 for sub\n"
<< "Enter 3 for mul\n"
<< "Enter 4 for div\n"
<< "Enter 5 for square\n"
<< "Enter 6 for square root\n"
<< "Enter 7 for distance\n"
<< "Enter 8 for time of free fall\n"
<< "Enter 0 for out" << endl;
cin >> Z;
if (Z == 1)
{
cout << "Enter the number =";
cin >> m >> n;
o2.sum(m, n);
}
else if (Z == 2)
{
cout << "Enter the number =";
cin >> m >> n;
x.sub(m, n);
}
else if (Z == 3)
{
cout << "Enter the number =";
cin >> m >> n;
x.mul(m, n);
}
else if (Z == 4)
{
cout << "Enter the number =";
cin >> m >> n;
x.div(m, n);
}
else if (Z == 5)
{
cout << "Enter the number =";
cin >> m;
o1.sq(m);
o1.out();
}
else if (Z == 6)
{
cout << "Enter the number =";
cin >> m;
o1.root(m);
o1.out();
}
else if (Z == 7)
{
cout << "X1,Y1 =";
cin >> m >> n;
cout << "X2,Y2 =";
cin >> o >> p;
o1.dis(m, n, o, p);
o1.out();
}
else if (Z == 8)
{
cout << "Enter hight of object =";
cin >> m;
cout << "Enter constant acceleration =";
cin >> n;
o1.free_falll(m, n);
o1.out();
}
else if (Z == 0)
{
break;
}
cout << "\n"
<< endl;
}
break;
}
return 0;
}
/*
*/