Skip to content
MathsGenie logo
Open app

Course home

  1. GCSE
  2. Computer Science Edexcel
  3. Question bank

Computational thinking

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
Question 41

An automated greenhouse ventilation system uses the following algorithm to control sensors and actuators, but it does not make efficient use of selection structures.

1   WHILE (systemActive = True) DO
2
3       RECEIVE tempSensor FROM TEMP_SENSOR
4       IF (tempSensor > 25) THEN
5           SET fanStatus TO "On"
6       END IF
7
8       RECEIVE humiditySensor FROM HUMIDITY_SENSOR
9       IF (humiditySensor < 40) THEN
10          SET misterStatus TO "On"
11      END IF
12
13      RECEIVE lightSensor FROM LIGHT_SENSOR
14      IF (lightSensor < 200) THEN
15          SET lightStatus TO "On"
16      END IF
17
18      IF (tempSensor <= 25) THEN
19          SET fanStatus TO "Off"
20      END IF
21
22      IF (humiditySensor >= 40) THEN
23          SET misterStatus TO "Off"
24      END IF
25
26      IF (lightSensor >= 200) THEN
27          SET lightStatus TO "Off"
28      END IF
29
30  END WHILE

Write replacement code to control the greenhouse fan (fanStatus) that would improve the efficiency of this algorithm.

[2]

Computational thinking Questions

  1. GCSE
  2. /Computer Science
  3. /Computational thinking