Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 2 of 2.
Fill each gap in order. The record is found with its hash value, so SEEK goes to that location and GETRECORD reads it.
AccountFile ← "AccountRecords.dat" OPENFILE AccountFile FOR RANDOM OUTPUT "Please enter an account number" INPUT Customer.AccountNumber Location ← Hash(Customer.AccountNumber) SEEK AccountFile, Location GETRECORD AccountFile, Customer OUTPUT Customer // output customer record CLOSEFILE AccountFile
First gap: AccountFile [1]
Second line: OPENFILE and FOR RANDOM [1]
Hash parameter: Customer.AccountNumber [1]
SEEK gap: AccountFile [1]
Last gap: GETRECORD before AccountFile and Customer after it [1]
Write: Exception handling is responding to an unexpected event while the program is running, so that the program does not stop (crash) unexpectedly. [1]
Write any two causes:
A programming error, for example dividing by zero. [1]
A user error, for example typing a wrong file name. [1]
Other accepted causes: hardware failure or a runtime error.
▶ Topic lesson
A lesson on this topic · by James Gan. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.