Skip to content

Course home

Sign up

Computational thinking

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
Question 18

An automated smart-grid battery storage controller uses the following algorithm to manage system operations, but it does not make efficient use of selection structures.

1   WHILE (controllerActive = True) DO
2
3       RECEIVE gridDemand FROM GRID_SENSOR
4       IF (gridDemand > 50) THEN
5           SET batteryMode TO "Discharging"
6       END IF
7
8       RECEIVE batteryTemp FROM TEMP_SENSOR
9       IF (batteryTemp > 45) THEN
10          SET coolingFan TO "High"
11      END IF
12
13      RECEIVE stateOfCharge FROM SOC_SENSOR
14      IF (stateOfCharge < 20) THEN
15          SET lowPowerWarning TO "Active"
16      END IF
17
18      IF (gridDemand <= 50) THEN
19          SET batteryMode TO "Charging"
20      END IF
21
22      IF (batteryTemp <= 45) THEN
23          SET coolingFan TO "Low"
24      END IF
25
26      IF (stateOfCharge >= 20) THEN
27          SET lowPowerWarning TO "Inactive"
28      END IF
29
30  END WHILE

Write replacement code to control the battery operating mode (batteryMode) that would improve the efficiency of this algorithm.

[2]
Markscheme

Computational thinking Questions

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

Question bank