A coastal rescue team uses a program to calculate fuel for a boat trip. The program receives a distance in nautical miles and calls a subroutine that return...

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

Question 1 Report

A coastal rescue team uses a program to calculate fuel for a boat trip. The program receives a distance in nautical miles and calls a subroutine that returns fuel needed at 2.4 litres per mile. The returned value is then displayed by the main program.

(a) When the distance is 15 miles, calculate the fuel returned. Show your working. [2]
(b) Explain why the subroutine should return a numeric value rather than a message such as Fuel calculated. [1]
(c) When the distance entered is 0, explain whether this is valid test data for the calculation. [1]
(d) Explain one validation rule for a distance entered by an operator. [1]

Answer Details

(a) Fuel is calculated at 2.4 litres per mile:

\[15 \times 2.4 = 36\]

The subroutine returns 36 litres. [2]

(b) It must return a numeric value because the main program needs a number to display or to use in further calculations. A message such as Fuel calculated cannot be used as the fuel amount. [1]

(c) Zero is valid boundary test data if a zero-distance trip is permitted. The calculation should then return 0 litres. [1]

(d) One suitable validation rule is that the distance must not be negative. Acceptable alternatives include requiring a numeric value or setting an agreed maximum distance. [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