Question 1 Report
The community swimming pool uses a program to calculate the cost of a group booking. The main program receives swimmers = 18 and pricePerSwimmer = 4.50. A trainee programmer writes the statement totalCost = swimmers * pricePerSwimmer. The value of totalCost is displayed as part of a message to the organiser. The programmer must use an arithmetic operator that works with numeric data, rather than joining text strings. The skeleton program will later include a subroutine that applies discounts to large groups.
(a) When the statement is run, state the value assigned to totalCost. [1]
(b) Explain why the * operator is used in this statement. [2]
The village cinema uses a ticket program for a Saturday matinee. A pupil modifies the code so that the number of free seat upgrades can be found. The customer has earned points = 147, and each upgrade costs 25 points. The program uses upgrades = points DIV 25. It must also calculate unused points with a second arithmetic statement. Both values are passed to a subroutine that creates the message printed on the ticket. The player-like user does not see the internal variables.
(a) When the program calculates upgrades, state its value. [1]
(b) Explain which arithmetic operation should be used to calculate the unused points. [2]
Swimming-pool calculation
totalCost is 81 or 81.0. [1]* operator performs multiplication. [1] It multiplies the number of swimmers by the cost for one swimmer, giving the total charge. [1] It is not used to join text: both values here are numeric.Cinema-points calculation
147 DIV 25 is 5, since \(5 \times 25=125\) and six upgrades would require 150 points. [1]MOD, or modulo, to calculate unused points. [1] It gives the remainder after complete groups of 25 have been removed: 147 MOD 25 = 22, so 22 points are unused. [1]Everything you need to excel in your exams