Question 1 Report
Fig. 1 shows a flowchart from a recycling centre program. An employee enters the mass of each aluminium can in grams. The program checks each input and adds acceptable cans to canCount. The variable mass is read again at the end of each loop. The sentinel value -1 indicates that there are no more cans. The employee says that a can of exactly 12 g must be counted, but a can of 11 g must not be counted.
Fig. 1: part of the recycling-centre flowchart
(a) Identify the construct represented by the lower diamond in Fig. 1. [1]
(b) Write the value of canCount after masses 12, 9 and 15 have been entered, starting from 0. [2]
(c) Complete the missing true branch in pseudocode so that the flowchart performs the required count, then state the input statement that must be repeated. [4]
(a) The lower diamond is a selection or IF construct [1]. It chooses a branch according to whether the condition is true or false.
(b) Starting with canCount = 0, mass 12 is counted, mass 9 is not, and mass 15 is counted. The final value is 2. [2]
(c) Exactly 12 g must be included, so the comparison needs >=:
IF mass >= 12 THEN
canCount = canCount + 1
END IF
INPUT massThe condition gains [1], the increment [1], the closing syntax [1], and the repeated input statement [1]. [4]
Everything you need to excel in your exams