-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator_by_franzen.cxx
125 lines (109 loc) · 1.81 KB
/
calculator_by_franzen.cxx
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
#include<iostream>
#include<cmath>
using namespace std;
void arithmetic(){
int op = 0;
float A = 0;
float B = 0;
cout<<"Select opeartion\n";
cout<<"[1] Addition\n";
cout<<"[2] Substraction\n";
cout<<"[3] Product\n";
cout<<"[4] Division\n";
cin>>op;
cout<<"Enter the 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 trignometric(){
int op = 0;
float val = 0.0;
cout<<"Select\n";
cout<<"[1] Sine\n";
cout<<"[2] Cosine\n";
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 eee = 0.0;
cout<<"Enter base:";
cin>>base;
cout<<"Enter expnent: ";
cin>>eee;
cout<<pow(base, eee)<<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<<"====Calculator App(By Franzen)====\n";
cout<<"[1] Arithmetic\n";
cout<<"[2] Trigonometric\n";
cout<<"[3] Exponential\n";
cout<<"[4] Logarithmic\n";
cout<<"Your choice:";
while(choice == 'y'){
cout<<"Enter the type of operation you want to calculate\n";
cin>>sel;
switch(sel){
case 1:
arithmetic();
break;
case 2:
trignometric();
break;
case 3:
exponential();
break;
case 4:
logarithmic();
break;
default:
cout<<"Invalid Operation";
}
cout<<"Do you want to continue? y/n"<<endl;
cin>>choice;
if(choice == 'n'){
break;
}
}
return 0;
}