A program is being developed to manage student book loans from a college library. Students may borrow up to five books at a time from the library. The programmer has defined a record type to define each loan. The record data items are: Data item Data type Comment StudentID STRING the unique ID of the student who has borrowed the book BookID STRING the unique ID of the book being borrowed OnLoan BOOLEAN TRUE if the book has not been returned The programmer has defined a global array Loan to store 5000 loan records. There are more elements in the array than books in the library. Unused elements have the StudentID set to an empty string. These may occur anywhere in the array. The programmer has defined the first program module: Module Description OKToBorrow() • called with a parameter of type STRING representing a StudentID • search the array for loan records for the specified student • output a suitable message to say whether the student may, or may not, borrow another book
- (a)Write efficient pseudocode for the module OKToBorrow()[7]
- (b)A second module is defined: Module Description ReturnBook() • called with two parameters of type STRING representing a StudentID and a BookID • searches the array for the relevant loan record • when found, sets OnLoan to FALSE and returns TRUE • if a loan record is not found, or the book has already been returned, then returns FALSE Write efficient pseudocode for the module ReturnBook() Assume that each student is only allowed to borrow each book only once. That means that there will be no more than one loan record for a given combination of student and book.[8]
- (c)It is decided to introduce a system of fines for books that have been borrowed for too long. Two new requirements are defined: 1. Each loan has a maximum length, represented as a number of days. 2. Each book in the library will be assigned one of three categories. Each category has a different maximum loan length. Record structure and program design changes are needed to meet these two requirements. Outline the changes that are necessary to meet the two requirements.[2]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2025). The mark or mark type is shown in brackets.
- [7] (a) Procedure heading, parameter and ending
- [7] (a) Loop through all elements in Loan array
- [7] (a) ...terminating if Max reached
- [7] (a) Test for correct StudentID field in a loop
- [7] (a) and that OnLoan = TRUE in a loop
- [7] (a) if so, then increment Count in a loop
- [7] (a) Output an appropriate message in both cases after the loop
- [8] (b) Loop through all elements in Loan array
- [8] (b) ...and book loan not found
- [8] (b) Attempt to reference an individual data item in a loop
- [8] (b) Correct test for StudentID and correct BookID in a loop
- [8] (b) If book not returned yet, then set OnLoan field to FALSE
- [8] (b) RETURN TRUE if book loan Found and not already returned
- [8] (b) RETURN FALSE if book loan Found and loan already returned
- [8] (b) RETURN FALSE if book loan not found
- [2] (c) Store date due back as a new data item / in the loan record
- [2] (c) Store date of loan and the loan length category as new data items / in the loan record
- [2] (c) New Records with Category (and Loan length field)
- [2] (c) (Use the loan length category of a book to) calculate the date due date
- [2] (c) Compare due date with today's date (to check if overdue / to calculate fine)
- [2] (c) Map loan length category to length of loan / date due back
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →