ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions

N5 Computing Science 2021 Question 13

7 marks · Selection and logical operators

Explain fully how this program informs the farmer when a box of mushrooms is full. The robot currently picks mushrooms that are no more than 4 cm in diameter and packs 20 mushrooms into a box. State the smallest size a picked mushroom could be. Explain why line 14 is necessary. The scanner on a second robot calculates how white each mushroom is and outputs this as a ‘whiteness’ reading between 0 and 10. Line 1 DECLARE maxSize AS REAL INITIALLY 4.0 Line 2 DECLARE fullBox AS INTEGER INITIALLY 20 Line 3 DECLARE count AS INTEGER INITIALLY 0 Line 4 DECLARE whiteness AS REAL INITIALLY 0.0 Line 5 WHILE <there are more mushrooms to scan> DO Line 6 RECEIVE mushroomSize FROM <scanner> Line 7 IF mushroomSize >= maxSize/2 AND mushroomSize <= maxSize THEN Line 8 Line 9 Line 10 Line 11 Line 12 Line 13 Line 14 Line 15 <pick and pack scanned mushroom> SET count TO count + 1 IF count = fullBox THEN SEND "Box Full" TO TOUCHSCREEN SEND "Replace with Empty Box" TO TOUCHSCREEN <pause until box replaced> SET count TO 0 END IF Line 16 END IF Line 17 END WHILE Line 4 of the original program has been edited. Describe how else the original program could be edited so that mushrooms of any size, with a whiteness reading of at least 9 would be picked by the robot. A farm uses a robot to scan mushrooms and measure their diameter. If they have grown to the correct size, the mushrooms are picked and packed into boxes. The program that controls the robot is shown below. Line 1 DECLARE maxSize AS REAL INITIALLY 4.0 Line 2 DECLARE fullBox AS INTEGER INITIALLY 20 Line 3 DECLARE count AS INTEGER INITIALLY 0 Line 4 DECLARE mushroomSize AS REAL INITIALLY 0.0 Line 5 WHILE <there are more mushrooms to scan> DO Line 6 RECEIVE mushroomSize FROM <scanner> Line 7 IF mushroomSize >= maxSize/2 AND mushroomSize <= maxSize THEN Line 8 Line 9 Line 10 Line 11 Line 12 <pick and pack scanned mushroom> SET count TO count + 1 IF count = fullBox THEN SEND "Box Full" TO TOUCHSCREEN SEND "Replace with Empty Box" TO TOUCHSCREEN Line 13 Line 14 Line 15 <pause until box replaced> SET count TO 0 END IF Line 16 END IF Line 17 END WHILE

Marking scheme

One mark each for reference to • Add 1 to/increment count variable • if count = 20 • message displayed (to farmer) 2 The count must be restarted for the next box of mushrooms. The count variable is reset back to 0 to start counting the next box of mushrooms. One mark each for • line 6 edited to input whiteness • the condition (on line 7) should be changed to whiteness >= 9 and whiteness <=10 Note that the condition whiteness = 9 or whiteness =10 is not appropriate in this case as whiteness is a real value.

Previous question: N5 Computing Science 2021 Question 12

Next question: N5 Computing Science 2021 Question 14