int main ()
{
int speed;
int hour;
int distance;
bool notValid;
int a=1;
do{
notValid=false;
cout << "\nWhat is the speed of the vehicle in mph? " ;
cin >> speed;
if (speed < 0)
{
cout << "\nYou have entered invalid data";
notValid=true;
}
} while (notValid);
do{
notValid=false;
cout << "\n How many hours has it traveled? " ;
cin >> hour;
if (hour < 1)
{
cout << "\nYou have entered invalid data";
notValid=true;
}
} while (notValid);
It is difficult to tell what you want, because you do not have any comments in the code, and your explanation of the problem is severely lacking. Note also that you have == instead of = in your for loop.