I need to make a user validation. If they enter a correct value, then the program will continue onto the next user input request.
If they enter an incorrect value (such as a negative number or a letter), display an error message such as "You entered an illegal character" or "value must not be negative".
I want to use a do while to do the user input validation cin.fail() and cin.clear()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int inputValidation ()
{
cout << "Enter the lowest gallon value to display <q to quit>: ";
cin >> lowGal;
cout << "\nEnter the highest gallon value to display <q to quit>: ";
cin >> hiGal;
do
{
if (lowGal < 0)
{
cout << "\nError: low gallon value must not be negative.\n";
cout << "Please re-enter low and high gallon values correctly.\n\n";
quit = true;
error = false;
}else (quit = false);
also with this do-while loops, I am receiving and infinite loop.