math program suggestions

Hey, this is my first post; as I am quite new to the website. Anyway, I just wrote this program and decided to see if anybody had any suggestions or thoughts on the source code.


#include <string>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;

int main()
{

double A, B, D;
char C, T, P;
for (;;) {
do {


cout << "\t\t\tGANTOR 82.1 Math Program\n\n\n";


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 (press Q)\n";
cout << "\nEnter your number here: ";
cin >> C;
} while ( C < '1' || C > '7' && C != 'Q');
if (C == 'Q') 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;



}
return 0;

}
}
return 0;
}

duplicate!!!
Just a quick tip for you and others new to C++ - it's very helpful for yourself, and others to read your code if it is organized and indented in a neat way, and posted here in the code format. For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;

int main()
{
      int a=1;

      if (a==1)
      {
            cout << "Hello world!\n";
      }

      return 0;
}

Notice how everything inside a set of brackets is indented except the brackets, so that they line up and you can tell what code is in what brackets.
Topic archived. No new replies allowed.