Hi,
I am having trouble with this input validation code. When I input values of the designated range (0-10) the first time through this loop it allows the program to continue down as it should, but when I enter an input not in the range like -1, 11, or a it invalidates it and prompts me to reenter. At this point when I enter a number that is 0-10 it still invalidates it and prompts me to reenter. Stays in an infinite loop. Can't figure it out. Please help!
(65-72)
construction, but in this case it could be a good thing. Put your conditions after the block, and put this:
1 2
cout << "Enter score given by judge #" << i2 << "\t";
cin >> scorenew;
inside the block. Use a logical flag bool retry = false; before the block, and use it to decide whether to print the error message or not by setting it true inside the block:
like this:
1 2 3 4 5 6 7 8 9
bool retry = false // first run through the loop you get a free pass; no error
do
{
if (retry) cout << "You are wrong; please try again" << endl;
retry = true; // after first time you get the error message until you get it right.
cout << "Enter a valid. . .";
cin >> value_being_entered;
}while (conditions_not_met);
The error message will only display on second and following retries.