Question 1 Report
The town council's recycling app calculates collection dates. A function called nextCollection(dayNumber) returns the day number of the next collection. The main program then calls a procedure named displayDate(dayNumber) to show the result in a message for a resident. A programmer has confused the two types of subroutine while revising the skeleton program. The council must be able to reuse the date calculation in both its website and its phone app.
(a) Explain the difference between the purpose of nextCollection and displayDate. [2]
(b) When the main program needs to store the calculated day in a variable, state which subroutine type is required. [1]
(c) Explain one advantage of reusing the same date-calculation function in both programs. [1]
A cinema booking program contains the procedure reserveSeat(row, seat). It checks whether the requested square on the seating board is empty. If it is empty, the procedure changes the board and displays a confirmation message. The programmer needs to ensure that the values supplied in the call match the parameters in the subroutine header. A customer has selected row 6 and seat 14. The following call is used: reserveSeat(6, 14).
(a) Explain what is meant by an argument in this call. [2]
(b) When the procedure starts, state the value held by parameter row. [1]
(c) Explain why the order of the two arguments is important. [1]
Collection-date program
nextCollection calculates and returns a day-number value. displayDate performs output by displaying that value and does not need to return one. [2]Cinema reservation
reserveSeat(6, 14), the values are supplied to row and seat. [2]row holds 6. [1]row and the second to seat. Reversing them could reserve the wrong position. [1]Everything you need to excel in your exams