Hey all this is my code
void Student::studentMenu() {
int choiceInput;
const string ErrorMsg;
cout << "-------------Student Menu--------------" << endl;
cout << "(1)Start Quiz" << endl;
cout << "(2)View History Score Table" << endl;
cout << "(0)Exit" << endl;
cout << "Option: " << endl;
try {
cin >> choiceInput;
if (choiceInput < 0 || choiceInput>2 || !cin)
{
throw (ErrorMsg);
}
while (choiceInput != 0) {
switch (choiceInput) {
case 1:
generateQuiz();
break;
case 2:
break;
case 0:
break;
}
break;
}
}
catch (string msg)
{
cout << "Please only enter valid integer from 0-3" << endl;
Student::studentMenu();
}
}
Basically it checks the user input and throw an exception if its a non integer larger than 3. After displaying the error message, it should redirect back to the student menu() page. The output is intended when i enter an integer like 5 but when i enter a char 'f' it keeps looping the error message
Please help me thanks!