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]
Bakery calculation
86 DIV 12 is 7, because \(7 \times 12=84\) and only 7 trays can be completely filled. [1]DIV is more suitable. [1]Bicycle-hire calculation
hoursCharged is 2. [1]Everything you need to excel in your exams