-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ppranav06/main
Initial commit - added the source
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} |