12-05-2009, 07:48 AM
You've still used two loops when you could have just used one.
Also using a double is pointless in this case since std::cout only shows 6 points of precision.
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";
cout << "Enter your choice: ";
cin >> option;
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;
default:
cout << "Invalid choice \n";
break;
}
} while(option!=5);
return 0;
}
Also using a double is pointless in this case since std::cout only shows 6 points of precision.
The little boat gently drifted across the pond exactly the way a bowling ball wouldn't.