Hi, its an assignment i need to do. The while loop working on well when i input an integer but when a letter is being input, the while loop run for infinity. I had seen through the other thread but still cannot understand how to do. Please help...

    {cout<<"The request is invalid, please try again."<<endl;
    cout<<"Please enter your choice again"<<endl;

If there are less than 10 choices, take in the choice as a character rather than an integer. Check to make sure the character is between '1' and '9' (or '0' and '9' if you want a choice 0).

Alternatively, if a 2+ digit answer is required, take in the input as a string and check each character to see if it's a digit (using the functions in <cctype> if permitted or the approach above if it's not).

then is normal to fail if you input a character...

define it as char or string

you made the condition as :


1 and 2 and 3 and 4 are intergers and the choice is character so you should make it as


the choice is declare as int...

choice is character

I said choice should be a character. In the OP's code it is not.