Question 1 Report
Fig. 1 shows a section of a flow chart used by a community library program. The program lets a borrower scan a membership card, enter a book code and then update the loan file. The programmer has decomposed the full task into smaller tasks before writing code in a code editor.
(a) Identify two inputs used by this section of the program. [2]
(b) Give two benefits of decomposing this library task before programming. [2]
(c) Write a suitable name for a subroutine that could contain the task of updating the loan file. [2]
(a) The two inputs are the membership code and the book code. They are the values read into the program before the loan file is updated. [2]
(b) Decomposition breaks a large task into manageable smaller tasks. It allows each task to be tested separately and can allow different programmers to work on separate tasks. It also supports reuse of a task such as file updating. Any two valid benefits gain credit. [2]
(c) A suitable descriptive subroutine name is updateLoanFile. Alternatives such as recordLoan or saveLoan are also valid because the name clearly describes the task. [2]
Everything you need to excel in your exams