Hello, I have already posted this in the beginner forums, but I thought I might as well post here as well. I have but recently written a program that uses some mathematic equations, and I was wondering if any one had some suggestions or thoughts on it, that would be great. Thanks.
cout << "\t\n\nWelcome, to GANTOR's Math program, what would you like to do?\n\n";
cout << "\t1. Solve with calculator\n";
cout << "\t2. Solve with Pythagorean's Theorem\n";
cout << "\t3. Quit\n";
cout << "\nEnter your number here: ";
cin >> C;
} while ( C < '1' || C > '7' && C != 'Q');
if (C == '3') break;
switch (C) {
case '1':
system ("CLS");
cout << "\t\t\tWelcome to the calculator portion\n\n\n";
cout << "\t\tSelect the operator you would like to use";
cout << "\n\nA. Addition" << endl;
cout << "\nB. Subtraction" << endl;
cout << "\nC. Division" << endl;
cout << "\nD. Multiplication" << endl;
cout << "\nE. Quit (press Q)" << endl;
cout << "\nEnter your letter here: ";
cin >> T;
if (C == 'Q') break;
switch (T) {
case 'A':
cout << "\nPlease enter a number: ";
cin >> A;
cout<<"Enter another number to be added: ";
cin >> B;
cout << A + B;
cout << "\n";
system ("PAUSE");
system ("CLS");
break;
case 'B':
cout << "\nPlease enter a number you would like to subtract from: ";
cin >> A;
cout << "Enter the number you would like to subtract from the first number: ";
cin >> B;
cout << A - B;
cout << "\n";
system ("PAUSE");
system ("CLS");
break;
case 'C':
cout << "\nPlease enter the numerator: ";
cin >> A;
cout << "Enter the denominator: ";
cin >> B;
cout << A / B;
cout << "\n";
system ("PAUSE");
system ("CLS");
break;
case 'D':
cout << "\nPlease enter a number: ";
cin >> A;
cout << "Enter another number to be multiplied: ";
cin >> B;
cout << A * B;
cout << "\n";
system ("PAUSE");
system ("CLS");
break;
}
return 0;
case '2':
system ("CLS");
cout << "\t\tWelcome to the Pythagorean Theorem portion\n\n\n";
cout << "\t\tThe equation is, as you know, (a2 + b2 = c2)\n\n";
cout << "\tPlease enter the variable you would like to solve for\n\n";
cout << "\n\t\ta\n\n";
cout << "\n\t\tb\n\n";
cout << "\n\t\tc\n\n";
cout << "\tEnter your side here: ";
cin >> C;
switch (C) {
case 'a':
cout << "\n\nPlease enter b's value: ";
cin >> A;
cout << "\n\nEnter c's value: ";
cin >> B;
// solve the equation here
cout << (B * B) - (A * A);
// print the answer
cout << " to the 2nd\n\n";
system ("PAUSE");
system ("CLS");
break;
case 'b':
cout << "\n\nPlease enter a's value: ";
cin >> A;
cout << "\n\nEnter c's value: ";
cin >> B;
// solve the equation here
cout << (A * A) - (B * B);
// print the answer
cout << " to the 2nd\n\n";
system ("PAUSE");
system ("CLS");
break;
case 'c':
cout << "\n\nPlease enter a's value: ";
cin >> A;
cout << "\n\nEnter b's value: ";
cin >> B;
cout << (A * A) + (B * B);
cout << " to the 2nd\n\n";
system ("PAUSE");
system ("CLS");
break;
while(1)
{
//take option here
cout << "\t1. Solve with calculator\n";
cout << "\t2. Solve with Pythagorean's Theorem\n";
cout << "\t3. Quit\n";
cout << "\nEnter your number here: ";
cin >> C;
switch (C) {
case 1:
//do some work
break;
case 2:
//do some work
break;
case 3:
return 0;
break;
default:
cout << "invalid option, try again please." << endl;
break;
}
}
at least tell user that he is entering some wrong choice. your loop will keep on taking inputs from user but he will never know whats wrong is going on.