The coastal monitoring team uses a program to process wave-height readings from a buoy. Readings are entered one at a time in metres. A reading of -1 ends t...

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

Question 1 Report

The coastal monitoring team uses a program to process wave-height readings from a buoy. Readings are entered one at a time in metres. A reading of -1 ends the session. Valid readings are from 0.0 to 12.0 inclusive. The program must count valid readings above 6.0, retain the largest valid reading, and display a warning message if any reading is above 9.0. The analyst has divided the skeleton program into getValidReading, updateStatistics and displayReport. During testing, the analyst will use boundary values and an invalid value to confirm that no invalid reading changes the statistics.

(a) Explain why the sentinel check for -1 must occur before range validation. [2]
(b) When a value of 12.4 is entered, state two actions the program should take. [2]
(c) Explain how updateStatistics can update the largest-reading variable. [2]
(d) When the valid readings are 4.2, 9.4 and 6.1, state the final count above 6.0 and the largest reading. [2]

Answer Details

(a) -1 is a sentinel, meaning it is a control value that ends input rather than a wave-height reading. [1] Testing it first ends the session instead of treating -1 as an invalid measurement and displaying a range error. [1]

(b) A reading of 12.4 is above the maximum valid value of 12.0, so the program should reject it or display a range error. [1] It should request another reading and must not update any statistics. [1]

(c) For each valid reading, compare it with the current largest-reading value. [1] Replace the stored largest value only when the new reading is greater. [1]

(d) The readings above 6.0 are 9.4 and 6.1, so the final count is 2. [1] The largest valid reading is 9.4 m. [1]

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