At a cinema kiosk, how can you choose Quit before the menu has even appeared?
You're at a cinema kiosk and the screen hasn't shown you any choices yet. Where should the program check whether you chose Quit: before it displays the menu, or after it reads your choice?
Start with finished set to false. The while loop tests not finished before it displays anything. The test is true, so the kiosk shows the menu, reads your choice and updates finished. If finished had started true, the first test would have skipped the menu.
Watch the kiosk show the menu before it tests anything. Choose one and finished becomes false. Until finished is false, so the loop repeats. Choose zero and finished becomes true, so the loop stops. Because the test comes after the body, this is a post-condition loop.
This time, suppose you choose zero as soon as the kiosk shows its menu. The program reads zero and sets finished to true. How many times has the menu appeared by the time the loop stops? Pick an answer.
In this alternative notation, do starts the body and the closing while tests whether to repeat. The menu still appears first. Choose one again: finished is false, so not finished is true and you repeat. Choose zero: finished is true, so not finished is false and you stop.
In this menu, nine means Quit. The original until test stops when choice equals nine. Keep the body first: display the menu, then read the choice. Reverse the condition so the closing while continues when choice is not nine. Two makes that test true; nine makes it false.
A different menu uses four for Quit. Its repeat loop ends with until choice equals four. You're converting it to a do loop. Pick the version that keeps the first menu display and stops on the same choice.
Try a Quit choice. In the original loop, finished is true, so until finished stops. Copy finished unchanged into the closing while test and true makes it repeat. Use while not finished instead: the test is false, so the loop stops as intended.
Quit choice names a constant: its value stays zero. Handle Choice declares finished as a Boolean variable and assigns it true or false. If you're still going, a second if inside the first checks for one and calls Continue Booking. Finally, Handle Choice returns finished to the caller.
If the exam asks how many times the menu is displayed when each session starts with Quit, trace the outer for loop twice. In each session, the inner loop displays the menu, reads your choice and calls Handle Choice before testing finished. Each inner loop stops after one display: two displays altogether.