A chemistry department stores pH results from a river survey in a file. For each sample, a student enters a location code and a pH value. The program should...

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

Question 1 Report

A chemistry department stores pH results from a river survey in a file. For each sample, a student enters a location code and a pH value. The program should display a message if the pH value is not between 0 and 14, then allow the student to enter the value again. A later program reads the file to draw a graph of pH against location.

(a) Explain why the range test is appropriate for the pH input. [2]
(b) State one output device that could display the message. [1]



Table 1 shows part of a comma-separated file used by a parcel depot. The dispatch program reads each line, calculates the total mass for a delivery route and then displays the route number and total. Staff must be able to add new parcel records without deleting records already collected during the shift.

ParcelIDRouteMass (kg)
P1048N32.6
P1049N31.4
P1050W13.2

(a) When processing the first two records, calculate the displayed total mass for route N3. [1]
(b) State the file operation used to add a new record while retaining the existing file contents. [1]
(c) Explain why a comma is useful as a separator in this file. [2]

Answer Details

River pH results

  1. A range test is appropriate because valid pH values lie from 0 to 14. The test prevents impossible values being placed in the results file used later for graphing. [2]
  2. A suitable output device is a monitor/screen. [1]

Parcel-depot file

  1. The two N3 masses are 2.6 kg and 1.4 kg:
    \[2.6 + 1.4 = 4.0\text{ kg}\]
    So the displayed total for route N3 is 4.0 kg. [1]
  2. Use append to add a new record while retaining existing file contents. [1]
  3. A comma separates the individual fields in each record. The program can therefore split the line and read the route and mass independently. [2]

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