123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
#include <iostream> #include <string> #include <ctime> using namespace std; int main() { bool done = false; while (done != true) { int Continue = 1; int answer = 0; int x = 0; int function = 0; cout << "Type in the function. \nPlease enter things like \n20x as 20 * x, and \nexponents like 9x^2 as 9 * x^2"; cout << endl << endl; cin >> function; // is cin in a fail state? if (!cin) { cin.clear(); cin.ignore(); } cout << "What is x? "; cin >> x; cout << "\n\nSolving..." << endl; answer = function; cout << "Answer is " << answer << endl; cout << endl << "Continue? 1 for yes, 2 for no."; cin >> Continue; if (Continue == 1) continue; else if (Continue == 2) { done = true; } } }