01-10-2010, 06:05 AM
(This post was last modified: 01-10-2010, 06:05 AM by Brainless Control.)
(01-10-2010, 05:58 AM)Master of the Universe Wrote: Here I don't have the time to debug your code, but I have an modification to offer you ;)or that lol,very smart move
Compiled and works as you wanted it to!
Code:#include <iostream>
using namespace std;
int option = 0;
double a = 0;
double b = 0;
int showMenu()
{
cout << ":::Calculator v1::: \n";
cout << "Enter a Number: \n";
cin >> a;
cout << "Enter a Number: \n";
cin >> b;
cout << "1. Multiplication \n";
cout << "2. Division \n";
cout << "3. Addition \n";
cout << "4. Subtraction \n";
cout << "5. Enter new numbers \n";
cout << "6. Quit \n";
cout << "Enter your choice: ";
cin >> option;
return option;
}
void Calc(int option, double num1, double num2) {
a = num1;
b = num2;
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:
break;
case 6:
cout << "Goodbye \n";
break;
}
}
int main()
{
do {
option = showMenu();
do {
Calc(option, a, b);
} while(option<1 || option>6);
} while(option!=6);
return 0;
}