12-05-2009, 05:02 AM
(This post was last modified: 12-05-2009, 05:06 AM by Brainless Control.)
Ok so i updated it a little bit
I added the double variable for more accurate results and the while(option!=5) for it to loop the menu after every result,before it didn't work as I forgot to put why the loop should stop at option 3 example so I added the Quit option,hope it's better.
Code:
#include <iostream>
using namespace std;
int main()
{
double a,b;
int option;
cout << ":::Calculator v1::: \n";
cout << "Enter a Number: \n";
cin >> a;
cout << "Enter a Number: \n";
cin >> b;
do {
cout << "1. Multiplication \n";
cout << "2. Division \n";
cout << "3. Addition \n";
cout << "4. Subtraction \n";
cout << "5. Quit \n";
do {
cout << "Enter your choice: ";
cin >> option;
} while(option<1 || option>5);
switch (option) {
case 1:
cout << "The Result is: " << a*b << '\n';
break;
case 2:
cout << "The Result is: " << a/b << '\n';
break;
case 3:
cout << "The Result is: " << a+b << '\n';
break;
case 4:
cout << "The Result is: " << a-b << '\n';
break;
case 5:
cout << "Goodbye \n";
break;
}
} while(option!=5);
return 0;
}