Question 1 Report
The music festival app displays a countdown until the next performance. Fig. 1 shows the planned calls made by the main program. The function minutesLeft(startTime, currentTime) calculates a number. The procedure showCountdown(minutes) uses that number to display a message. A developer has accidentally written showCountdown as a function and has included an unused return statement. The app must update each minute without repeating calculation commands in several screens.
(a) Explain why showCountdown should be a procedure. [2]
(b) When minutesLeft returns 12, state the argument passed to showCountdown. [1]
(c) Explain why the unused return statement should be removed. [1]
(d) When another screen needs the countdown, state which subroutine can be called again. [1]
(a) showCountdown should be a procedure because its purpose is to display an output message. It does not need to return a value to the main program. [2]
(b) If minutesLeft returns 12, the argument passed to showCountdown is 12. [1]
(c) The return statement should be removed because it is unnecessary and could mislead a programmer into thinking that showCountdown has the purpose of producing a returned result. [1]
(d) The program can call minutesLeft again to calculate a new countdown value and/or showCountdown again to display a countdown, depending on what the other screen needs. [1]
Everything you need to excel in your exams