-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalice-calculator.cpp
57 lines (56 loc) · 1.33 KB
/
alice-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
//Alice Calculator++
#include<iostream>
#include<iomanip>
using namespace std;
long double calculations (float a, float b, char op){
cout<<"Enter the first number: ";
cin>>a;
cout<<"Enter the second number: ";
cin>>b;
cout<<"Enter the operator: ";
cin>>op;
switch(op){
case '+':
case 'a':
cout<<endl<<a<<" + "<<b<<" = "<<a+b<<endl;
break;
case '-':
case 's':
cout<<endl<<a<<" - "<<b<<" = "<<a-b<<endl;
break;
case '*':
case 'm':
cout<<endl<<a<<" * "<<b<<" = "<<a*b<<endl;
break;
case '/':
case 'd':
cout<<endl<<a<<" / "<<b<<" = "<<a/b<<endl;
break;
default:
cout<<"Invalid operator"<<endl;
}
return 0;
}
int main(){
system("clear");
cout<<"Alice Calculator++"<<endl;
float n1,n2;
char op, option;
beginning:
cout<<endl<<"Choices:"<<endl<<"1 = Basic operations\nq/e = Exit"<<endl;
cout<<"Enter your choice: ";
cin>>option;
if (option=='1'){
calculations(n1,n2,op);
goto beginning;
}
else if (option=='e' | option=='E' | option=='q' | option=='Q'){
cout<<"Exiting..."<<endl;
return 0;
}
else{
cout<<"Invalid option"<<endl;
goto beginning;
}
return 0;
}