Convert the visitor's message for a planetarium booking to a short confirmation string. The booking program receives a full message such as "Iris, 3 tickets...

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

Question 1 Report

Convert the visitor's message for a planetarium booking to a short confirmation string. The booking program receives a full message such as "Iris, 3 tickets, Saturday". It must find the first comma, extract the visitor name, and display BOOKED: Iris. Staff are testing the code because some visitors enter no comma at all. The skeleton program should give a message instead of attempting a substring with an invalid pointer.

(a) Explain why the comma position must be tested before the name substring is created. [1]
(b) When the message is Iris, 3 tickets, Saturday, state the extracted visitor name. [1]
(c) Explain one suitable displayed message when no comma is found. [1]



Fig. 1 shows a parcel depot scanner beside a loading board. Drivers type a parcel reference after scanning its barcode. The skeleton program must show the depot prefix separately from the number so that parcels can be placed on the correct ladder rack. References are in the format two letters, a slash, then five digits, for example NW/38142. The program will reject an entry if the slash is absent.

(a) Explain why a find operation is useful before splitting a reference at the slash. [1]
(b) When the displayed reference is NW/38142, state the depot prefix. [1]
(c) Explain how the slash position can be used to select the number part of the string. [1]

Answer Details

Planetarium booking, (a) The comma position must be tested first because, without a comma, there is no valid end position for the name substring. [1]

Planetarium booking, (b) The extracted visitor name is Iris. [1]

Planetarium booking, (c) A suitable message is Enter name followed by a comma or Booking message format invalid. [1]

Parcel depot, (a) A find operation confirms that the slash separator exists and gives its position. [1]

Parcel depot, (b) The depot prefix is NW. [1]

Parcel depot, (c) Use the slash position to begin a substring at the next character, then take the remaining characters. [1] For NW/38142, this selects 38142.

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning