-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
70 lines (61 loc) · 1.67 KB
/
main.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
#include <iostream>
#include "Calculator.hpp"
using namespace std;
// //
char operation, control_2;
float number1, number2, result;
bool control = true;
// //
int main()
{
Calculate calculate;
cout << "Welcome to our calculator" << endl << "You can do addition, subtraction, multiplication and division operations here." << endl;
while (control == true)
{
cout << "\nplease choose an action(+,-,*,/): ";
cin >> operation;
cout << "\nplease choose the first number: ";
cin >> number1;
cout << "\nplease choose the secont number: ";
cin >> number2;
switch (operation)
{
case '+':
result = calculate.sum(number1,number2);
break;
case '-':
result = calculate.sub(number1,number2);
break;
case '*':
result = calculate.mul(number1,number2);
break;
case '/':
if (number2 != 0)
{
result = calculate.div(number1,number2);
}
else
{
cout << "Error: Division by zero is not possible!" << endl;
}
break;
default:
cout << "Please enter a valid transaction!" << endl;
break;
}
cout << "The result: " << result << endl;
cout << "\nDo you want to continue calculating?(y/n): ";
cin >> control_2;
if (control_2 == 'y')
{
control = true;
}
else
{
control = false;
}
}
cout << "Good Bye\n" << endl;
system("pause");
return 0;
};