-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkalkulator-else-if.cpp
124 lines (118 loc) · 4.11 KB
/
kalkulator-else-if.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
#include <iostream>
#include <string>
#include <conio.h>
#include <math.h>
#define PI 3.141592653589793238463
using namespace std;
int main()
{
char choice;
while(true)
{
double a, b, hasil;
int pil, x, y, hasil1;
cout << "---------------------------------------------";
cout << "\n";
cout << " Calculator By K4ncu1 ";
cout << "\n Using Else If ";
cout << "\n";
cout << "---------------------------------------------";
cout << "\n";
cout << " || Arithmetic Operations : ||" << endl;
cout << " || 1. Addition 8. Squared ||" << endl;
cout << " || 2. Subtraction 9. Sinus ||" << endl;
cout << " || 3. Multiplication 10. Cosinus ||" << endl;
cout << " || 4. Division 11. Tangen ||" << endl;
cout << " || 5. Modulus 12. Logaritma ||" << endl;
cout << " || 6. Squared Root 13. Logaritma10 ||" << endl;
cout << " || 7. Cube Root ||" << endl;
cout << "---------------------------------------------" << endl;
cout << "Input Options : ";
cin >> pil;
cout << "\n";
if (pil==1){
cout << "Enter The First Number : ";
cin >> a;
cout << "Enter The Second Number : ";
cin >> b;
hasil = a + b;
cout << "\nAddition Results : " << a << " + " << b << " = " << hasil;
}else if (pil==2){
cout << "Enter The First Number : ";
cin >> a;
cout << "Enter The Second Number : ";
cin >> b;
hasil = a - b;
cout << "\nSubtraction Results : " << a << " - " << b << " = " << hasil;
}else if (pil==3){
cout << "Enter The First Number : ";
cin >> a;
cout << "Enter The Second Number : ";
cin >> b;
hasil = a * b;
cout << "\nMultiplication Results : " << a << " * " << b << " = " << hasil;
}else if (pil==4){
cout << "Enter The First Number : ";
cin >> a;
cout << "Enter The Second Number : ";
cin >> b;
hasil = a / b;
cout << "\nDivision Results : " << a << " / " << b << " = " << hasil;
}else if (pil==5){
cout << "Enter The First Number : ";
cin >> x;
cout << "Enter The Second Number : ";
cin >> y;
hasil1 = x % y;
cout << "\nModulus Results : " << x << " % " << y << " = " << hasil1;
}else if (pil==6){
cout << "Enter The Number : ";
cin >> a;
cout << "\nSquared Root of : " << a << " = " << sqrt(a);
}else if (pil==7){
cout << "Enter The Number : ";
cin >> a;
cout << "\nCube Root of : " << a << " = " << cbrt(a);
}else if (pil==8){
cout << "Enter The Number : ";
cin >> x;
cout << "Enter Squared : ";
cin >> y;
cout << "\nSquared Results : " << x << " ^ " << y << " = " << pow(x,y);
}else if (pil==9){
cout << "Enter The Number : ";
cin >> a;
cout << "Sin(" << a << ") = " << sin(a*(PI / 180.0));
}else if (pil==10){
cout << "Enter The Number : ";
cin >> a;
cout << "Cos(" << a << ") = " << cos(a*(PI / 180.0));
}else if (pil==11){
cout << "Enter The Number : ";
cin >> a;
cout << "Tan(" << a << ") = " << tan(a*(PI / 180.0));
}else if (pil==12){
cout << "Enter The Number : ";
cin >> a;
cout << "\nLog(" << a << ") = " << log(a);
}else if (pil==13){
cout << "Enter The Number : ";
cin >> a;
cout << "\nLog10(" << a << ") = " << log10(a);
}else{
cout << "Your Operator is Wrong !!!";
}
cout<<"\n\nWant to Try Again?(Y/N)"<<endl;
cin >> choice;
if(choice == 'Y'|| choice =='y'){
continue;
}else if(choice == 'N'||choice == 'n'){
cout << "\n---------------------------------------------";
cout << "\n";
cout << " Thank You For Trying Me! ";
cout << "\n";
cout << "---------------------------------------------";
}
return 0;
}
}