A smart thermostat controller uses an algorithm to manage a home's heating system based on a target temperature.
01 SEND "Smart Home Heating System Active" TO DISPLAY
02 SEND "Enter desired temperature in Celsius:" TO DISPLAY
03 RECEIVE targetTemp FROM (INTEGER) KEYBOARD
04 SEND "Target temperature set to " & targetTemp & " degrees" TO DISPLAY
05
06 IF (targetTemp > 24) THEN
07 SET heaterState TO "OFF"
08 SEND "Warning: High temperature threshold" TO DISPLAY
09 ELSE
10 IF (targetTemp > 18) THEN
11 SET heaterState TO "ECO"
12 ELSE
13 SET heaterState TO "ON"
14 END IF
15 END IF
State the programming construct demonstrated by lines 01 to 04 of the algorithm.
50 exam-style questions on Edexcel GCSE Computer Science Constructs, covering Structural components of programs and Writing programs with control constructs. Each one has a worked solution and a mark scheme showing where the marks go.