01-09-2010, 07:23 AM
Update:
Ok so I'm back from holidays,I was kinda bored today so I decided to add a goto statement in it to re-do the put new number thing and not exit and re-open the program to do it.
Ok so I'm back from holidays,I was kinda bored today so I decided to add a goto statement in it to re-do the put new number thing and not exit and re-open the program to do it.
Code:
#include <iostream>
using namespace std;
int main()
{
double a,b;
int option;
labelgoto:
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. Enter new numbers \n";
cout << "6. Quit \n";
do {
cout << "Enter your choice: ";
cin >> option;
} while(option<1 || option>6);
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:
goto labelgoto;
break;
case 6:
cout << "Goodbye \n";
break;
}
} while(option!=6);
return 0;
}