Question 1 Report
Fig. 1 shows a flowchart for a parcel-locker program. The program reads a locker number, checks it, and then repeats this process while more customers are waiting. A programmer says the decision in the flowchart should be replaced by a sequence of commands because the program is already inside a loop. The service manager needs the structured program to reject locker numbers outside the range 1 to 48 and to display a useful message.
(a) Explain the purpose of the decision in Fig. 1. [2]
(b) When lockerNo is 52, state the path the program follows. [2]
(c) Explain why the error message should be displayed before the next loop iteration. [2]
(a) The decision validates the input: it tests whether lockerNo is in the permitted inclusive range 1 to 48. [1] It then selects the appropriate path: open the locker for a valid number, or display an error for an invalid one. [1]
(b) Since 52 is greater than 48, the condition is false, so the program follows the No path. [1] It displays the error message and does not open a locker. [1]
(c) The error must be displayed before the loop restarts so the customer receives feedback that their entry was invalid. [1] They can then enter a corrected locker number on the next iteration. [1]
Everything you need to excel in your exams