Computer Science · Oct / Nov 2020 · Paper 21 · Question 3
0478
As printed in the paper
The question as text
This pseudocode algorithm calculates the weight and number of bags in a load of firewood. The weight in kilograms of each bag is input. The algorithm finishes when either 50 bags have been weighed, or as soon as the total weight exceeds 1000 kilograms. Only then are the total weight and the number of bags in the load output. 01 TotalWeight ← 1000 02 BagCount ← 0 03 MaxBag ← 50 04 MaxWeight ← 1000 05 REPEAT 06 OUTPUT "Please Enter weight of bag" 07 INPUT Weight 08 TotalWeight ← TotalWeight + Weight 09 BagCount ← BagCount + 1 10 OUTPUT "Number of bags in the load is ", BagCount 11 UNTIL TotalWeight > MaxWeight AND BagCount >= MaxBag 12 OUTPUT "Total weight of the load is ", MaxWeight
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
3(a)[4]
Line 1/2/3/4/8/9
Lines 5–11
Line 9
Line 8
3(b)[4]
One mark for error and correction
Line 1 TotalWeight ← 0
Line 10 move OUTPUT "Number of bags in the load is ", BagCount to end / after line 11
Line 11 UNTIL TotalWeight > MaxWeight OR BagCount >= MaxBag Line 12 OUTPUT "Total weight of the load is ", TotalWeight
3(c)[4]
Any four from:
After line 11
Divide TotalWeight by
… BagCount
Assign a new variable AverageWeight ← TotalWeight / BagCount Output the result OUTPUT AverageWeight
With a message "Average weight of a bag of firewood is "
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

