#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
// Variable declarations
unsigned seed = time(0);
srand(seed);
int answer = 0;
int number1 = rand() % 500 + 1;
int number2 = rand() % 500 + 1;
int useranswer = 0;
int option;
cout << " Math Tutor Menu" << endl;
cout << "------------------------------" << endl;
cout << "1. Addition problem" << endl;
cout << "2. Subtration problem" << endl;
cout << "3. Multiplication problem" << endl;
cout << "4. Division problem" << endl;
cout << "5. Quit this program" << endl;
cout << "-------------------------------" << endl;
cout << "Enter your choice (1-5): ";
cin >> option;
if(0<option<6){
while(option = option){
if (option == 1){
number1 = rand() % 500 + 1;
number2 = rand() % 500 + 1;
cout << " " << number1 << endl;
cout << "+ " << number2 << endl;
cout << "______" << endl;
answer = number1 + number2;
cout << "Please enter the answer: ";
cin >> useranswer;
if(useranswer == answer){
cout << "Congratulations! That's the correct answer." << endl;
}
else{
cout<< "Sorry. The correct answer is " << answer <<endl;
}
break;
} else if (option == 2){
number1 = rand() % 500 + 1;
number2 = rand() % 500 + 1;
cout << " " << number1 << endl;
cout << "- " << number2 << endl;
cout << "______" << endl;
if(number1>=number2){
answer = number1 - number2;
cout << "Please enter the answer: ";
cin >> useranswer;
}
else{
answer = number2 - number1;
cout << "Please enter the answer: ";
cin >> useranswer;
}
if(useranswer == answer){
cout << "Congratulations! That's the correct answer." << endl;
}
else{
cout<< "Sorry. The correct answer is " << answer <<endl;
}
break;
} else if (option == 3){
number1 = rand() % 100 + 1;
number2 = rand() % 9 + 1;
cout << " " << number1 << endl;
cout << "x " << number2 << endl;
cout << "______" << endl;
answer = number1 * number2;
cout << "Please enter the answer: ";
cin >> useranswer;
if(useranswer == answer){
cout << "Congratulations! That's the correct answer." << endl;
}
else{
cout<< "Sorry. The correct answer is " << answer <<endl;
}
break;
} else if (option ==4){
number2 = rand() % 9 + 1;
number1 = number2*(rand() % 50 + 1);
cout << " " << number1 << endl;
cout << " ÷ " << number2 << endl;
cout << "______" << endl;
answer = number1 / number2;
cout << "Please enter the answer: ";
cin >> useranswer;
if(useranswer == answer){
cout << "Congratulations! That's the correct answer." << endl;
}
else{
cout<< "Sorry. The correct answer is " << answer <<endl;
}
break;
} else if (option==5){
cout << "Exiting program."<< endl; return 0;
}
else{
cout << "That is not a choice." <<endl;
}
return 0;
}
}
}
I am struggling to print the bottom statement "That is not a choice" and to bring it back to the menu for the user to choose 1-5. This is a math program I have almost completed, this is the final part I need to complete, thank you in advance! I am editing this in notepad++. I know there is some more improvements I could add but it is function other than this final error statement I am trying to build in.