For each delivery, the bakery's ordering program calculates how many trays are needed. A tray holds 12 rolls. The program is given rollsOrdered = 86 and use...

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

Question 1 Report

For each delivery, the bakery's ordering program calculates how many trays are needed. A tray holds 12 rolls. The program is given rollsOrdered = 86 and uses fullTrays = rollsOrdered DIV 12. The manager needs only the number of completely filled trays at this stage. A later command in the skeleton program checks for rolls that must go on a partly filled tray. The result is stored as an integer, then displayed on the packing list.

(a) When the DIV operation is completed, state the value of fullTrays. [1]
(b) Explain why ordinary division would be less suitable for this variable. [2]



Fig. 1 shows code from a bicycle-hire kiosk. A rider enters the time a bicycle was hired in minutes. The kiosk charges for every started hour, so the programmer first adds 59 before using integer division. The variable hoursCharged is then used by a subroutine that calculates the final cost. The code has been tested with a 61-minute hire. A message on the kiosk screen tells the rider how many hours have been charged.

(a) When the code shown is run with 61 minutes, state the value of hoursCharged. [1]
(b) Explain why 59 is added before the DIV 60 operation. [2]

Answer Details

Bakery calculation

  1. (a) 86 DIV 12 is 7, because \(7 \times 12=84\) and only 7 trays can be completely filled. [1]
  2. (b) Ordinary division would give a fractional value, \(86 \div 12=7.166\ldots\). [1] The variable is intended to store only the count of whole, complete trays, so DIV is more suitable. [1]

Bicycle-hire calculation

  1. (a) The calculation is \((61+59) \text{ DIV } 60 = 120 \text{ DIV } 60 = \mathbf{2}\). Therefore hoursCharged is 2. [1]
  2. (b) Adding 59 makes any non-zero part of an hour reach the next whole multiple of 60 before integer division, so it rounds the charge up. [1] Thus 61 minutes is charged as 2 hours rather than 1 hour. [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