Loading....

Computer Science 9210 | Paper 1 Mock 01 | Programming (on-screen)

Question 1 Report

The attendance program is to be used at a college workshop. At the start of each session, a technician enters a student ID at a keyboard. The main program must reject an empty entry and IDs that are not exactly six digits before it writes a record to the attendance file. The file is later read by a separate program to display the names of absent students.

(a) Explain why validation is needed before the new attendance record is saved. [2]
(b) When the file is opened for the first time on a new day, state the most suitable file mode. [1]



In the box-office program for a small theatre, each successful booking is written to a daily file. A customer enters the number of seats required, and the program displays either a confirmation message or an error message. The manager wants the program to prevent a booking of zero seats and to keep all earlier bookings in the same file.

(a) Explain why the number of seats should be validated as greater than zero. [2]
(b) When a later booking is saved, state the file mode that should be used. [1]

Answer Details

Workshop attendance

  1. Validation prevents invalid or incomplete student IDs being stored. This ensures later searches and absence reports use reliable records. [2]
  2. For the first file opening on a new day, use write/create mode. [1]

Theatre bookings

  1. The number of seats must be greater than zero because zero seats is not a valid booking. Accepting it would create inaccurate booking totals and records. [2]
  2. For a later booking, use append mode so earlier bookings remain in the daily file. [1]
1
2
3
4
5
6
7
8
9
10
11