Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- void main()
- {
- float a,b,i;
- cout<< "This is a simple no GUI calculator which can Add, Subtract, Multiply, Divide.\n";
- cout<< "Enter '1' to add, '2' to Subtact, '3' to Multiply, '4' to Divide.\n";
- cin>> i;
- cout<< endl;
- switch(i)
- {
- case 1:
- cout<< "Your option was Addition.\n";
- cout<< "Enter the First number...\n";
- cin>> a;
- cout<< endl;
- cout<< "Enter the Second number...\n";
- cin>> b;
- cout<< endl;
- cout<< "Sum of the numbers is "<<a+b;
- cout<< endl;
- break;
- case 2:
- cout<< "Your option was Subraction. Format is 'First number-Second number'.\n";
- cout<< "Enter the First number...\n";
- cin>> a;
- cout<< endl;
- cout<< "Enter the Second number...\n";
- cin>> b;
- cout<< endl;
- cout<< "Difference of the numbers is "<<a-b<<".\n";
- break;
- case 3:
- cout<< "Your option was Multiplication. The Multiplication is only of two numbers.\n";
- cout<< "Enter the First number...\n";
- cin>> a;
- cout<< endl;
- cout<< "Enter the Second number\n...";
- cin>> b;
- cout<< endl;
- cout<< "Product of the numbers is "<<a*b<<".\n";
- break;
- case 4:
- cout<< "Your option was Division. The first number is divided by the second number.\n";
- cout<< "Enter the First number...\n";
- cin>> a;
- cout<< endl;
- cout<< "Enter the Second number...\n";
- cin>> b;
- cout<< endl;
- cout<< "Difference of the numbers is "<<a/b<<".";
- break;
- default:
- cout<< "The program does not understand your input. Try one of the the supported ones.\n";
- break;
- }
- cout<< "Thank you for trying this program";
- }
Advertisement
Add Comment
Please, Sign In to add comment