Return to an input that was wrong!!

Hi everyone,

I'm trying to write a program that calculates the parking time and cost. I have an error mesage stating that the 'Exit time must be less than Entry time' if enter incorrectly. What my issue is that, i have to redo the inputs again, where i only want to re-enter the exit time. What process do i need to follow to be able to return to the exit time and continue with the rest of the program.

Re: Return to an input that was wrong!!

Instead of your if statement you can use a while loop with the same condition. Inside the while loop you would ask the user for the exit time again and redo your calculation. Once the condition is met it will continue with the program.

EDIT: I just reread your code and I think you would be better off moving this while loop above your calculations of exit, enter, and minutes so you don't have to recalculate them when the exitTime changes