-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdvanced_Calculator.cpp
151 lines (121 loc) · 2.83 KB
/
Advanced_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
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
#include <iostream>
#include <cmath>
using namespace std;
void arithmetic()
{
int op = 0;
float A = 0;
float B = 0;
cout << "Select Opeartion";
cout << "[1] Addition";
cout << "[2] Substraction";
cout << "[3] Product";
cout << "[4] Division";
cin >> op;
cout << "Enter frist number : ";
cin >> A;
cout << "Enter second number : ";
cin >> B;
cout << "Result : ";
switch (op)
{
case 1:
cout << (A + B);
break;
case 2:
cout << (A - B);
break;
case 3:
cout << (A * B);
break;
case 4:
cout << (A / B);
break;
default:
cout << "Invalid Operation";
break;
}
cout << endl;
}
void trigonometric()
{
int op = 0;
float val = 0.0;
cout << "Select";
cout << "[1] Sinen";
cout << "[2] Cosinen";
cout << "Op : ";
cin >> op;
cout << "Enter value : ";
cin >> val;
if (op == 1)
{
cout << sin(val);
}
else if (op == 2)
{
cout << cos(val);
}
else
{
cout << "Invalid operation";
}
cout << endl;
}
void exponential()
{
float base = 0.0;
float e = 0.0;
cout << "Enter base :";
cin >> base;
cout << "Enter expnent : ";
cin >> e;
cout << pow(base, e) << endl;
}
void logarithmic()
{
float value = 0.0;
cout << "Enter the value to calculate the log(e) : ";
cin >> value;
cout << log(value) << endl;
}
int main()
{
int sel = 0;
char choice = 'y';
cout << "Advanced Calculator Developed By Muhammad Mubeen Channa";
cout << "[1] Arithmetic";
cout << "[2] Trigonometric";
cout << "[3] Exponential";
cout << "[4] Logarithmic";
cout << "\nYour choice :";
while (choice == 'y')
{
cout << "Enter the type of operation you want to calculate";
cin >> sel;
switch (sel)
{
case 1:
arithmetic();
break;
case 2:
trigonometric();
break;
case 3:
exponential();
break;
case 4:
logarithmic();
break;
default:
cout << "Invalid Operation";
}
cout << "Do you want to continue? y or n : ";
cin >> choice;
if (choice == 'n')
{
break;
}
}
return 0;
}