Trying to create a while loop that will re-ask to enter correct input. In this case, the correct input needs to be a number. When I test it and put in a non-number answer, it ends the program. The while loop isn't working.
if (variableQuestionsVf == "Yes" || variableQuestionsVf == "yes")
{
cout << "Input final velocity (in m/s): " ;
while (cin >> finalVelocity)
{
istringstream s(sVf);
s >> value;
if (value <= 0 || value >= 0) //Validating input for final velocity
break;
cout << "Please enter final velocity (in m/s): " ;
}
}
Is there an easier way?