My very simple program is to register hotel guests. At the beginning, the user should input 1, 2, 3 or 4 to go to the next step.
What is the best way to catch an input which is not in '1,2,3,4' then report an error to the user and ask for a new input.
This is a fundamental problem in programming I think. The user inputs an unexpected input, maybe just presses 'enter'. How do we look at the input, compare it with what is exepected, and if it is not in the set of expected values, go back to the beginning?