0

I am having trouble trying to get my code to work. If I pick selection 1 or 2 the cout statements execute but it does not wait for the cin and the program closes.

```
#include <iostream>
#include <cstdlib>
#include <string>
#include "poly.h"
using namespace std;
void enterPoly1(Polynomial&);
void enterPoly2(Polynomial&);
void addPoly(Polynomial&, Polynomial&, Polynomial&);
void subPoly(Polynomial&, Polynomial&, Polynomial&);
int main()
{
char choice;
Polynomial p1;
Polynomial p2;
Polynomial p3;
do {
cout << "Welcome to the Polynomial Program!!" << endl;
cout << "In this program you can enter two polynomials," << endl;
cout << "and then choose to add or subtract thos polynomials" << endl;
cout << "PLEASE NOTE: you must use proper polynomial syntax when entering." << endl;
cout << "This format is (Num)x^2 + or - (Num)x + or - (Num)" << endl;
cout << "Please use the following choices to begin (enter the number of your choice):" << endl;
cout << "1. Enter Polynomial 1" << endl;
cout << "2. Enter Polynomial 2" << endl;
cout << "3. Choose Addition" << endl;
cout << "4. Choose Subtraction" << endl;
cout << "5. Quit" << endl;
cin >> choice;
switch (choice)
{
case '1':
enterPoly1(p1);
break;
case '2':
enterPoly2(p2);
break;
case '3':
subPoly(p1, p2, p3);
break;
case '4':
subPoly(p1, p2, p3);
break;
case '5':
cout << "Thanks for playing - GOODBYE!" << endl;
break;
}
} while (choice != '5');
system ("PAUSE");
return 0;
}
void enterPoly1(Polynomial& p1) {
cout << "PLEASE NOTE: you must use proper polynomial syntax when entering." << endl;
cout << "This format is (Num)x^2 + or - (Num)x + or - (Num)" << endl;
cout << "Also, use lower case x variables!" << endl;
cout << "Enter Polynomial 1: " << endl;
cin >> p1;
}
void enterPoly2(Polynomial& p2) {
cout << "PLEASE NOTE: you must use proper polynomial syntax when entering." << endl;
cout << "This format is (Num)x^2 + or - (Num)x + or - (Num)" << endl;
cout << "Also, use lower case x variables!" << endl;
cout << "Enter Polynomial 2: " << endl;
cin >> p2;
}
```

*Edited 3 Years Ago by tensity*