Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 2 of 2.
A composite type starts with TYPE and ends with ENDTYPE. Inside, declare one field for each item of data. Dates use DATE, yes/no uses BOOLEAN and a telephone number is a STRING (it can start with 0).
TYPE TAppointments
DECLARE FirstName : STRING
DECLARE LastName : STRING
DECLARE DateOfBirth : DATE
DECLARE Telephone : STRING
DECLARE LastAppointment : DATE
DECLARE NextAppointment : DATE
DECLARE TreatmentsComplete : BOOLEAN
ENDTYPETYPE TAppointments and ENDTYPE correct [1]
Two correct declarations (for example the name fields) [1]
Two more correct declarations (for example the dates) [1]
Two more correct declarations (for example Telephone and TreatmentsComplete) [1]
A single Name field is also accepted.
Fill each gap using the random-file commands: OPENFILE ... FOR RANDOM, SEEK, GETRECORD, EOF and CLOSEFILE.
OPENFILE DentalFile FOR RANDOM
Count ← 1
REPEAT
SEEK DentalFile, Count
GETRECORD DentalFile, DentalRecord[Count]
OUTPUT DentalRecord[Count]
Count ← Count + 1
UNTIL EOF(DentalFile)
CLOSEFILE DentalFileWrite DentalFile FOR RANDOM after OPENFILE [1]
Write Count before ← 1 [1]
Write GETRECORD DentalFile, DentalRecord[Count] after SEEK [1]
Write UNTIL EOF before (DentalFile) [1]
Write CLOSEFILE DentalFile on the last line [1]
▶ Whole paper
Video solution of the whole paper · by qiphyedu. 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.