Cover lesson · Computer Science · Year 8 · Intermediate
DCF: Data and computational thinking → Problem-solving and modelling · LNF: Numeracy → Logical reasoning
Name: Class: Date:
What this practises: computational thinking and logical reasoning in Computer Science. Pupils dry-run a faulty flood-warning flowchart against 8 hourly river and rainfall readings using a trace table, uncover two logic bugs (OR used instead of AND, and < used instead of >=), verify their fix including a boundary test, and write the corrected algorithm in pseudocode.
Board: open the supply teacher presentation for board slides, timers and script.
Print: this worksheet, one per pupil, and the stimulus sheet “Afon Glyn flood sensor readings and trainee flowchart”, one between two. No computers or calculators needed.
Run: 5 min starter and read stimulus · 5 min key words · 10 min Step 1, trace the faulty flowchart · 10 min Step 2, diagnose and fix the 2 bugs · 12 min Steps 3 and 4, re-trace and write pseudocode · 5 min partner check · 3 min plenary check. Total 50 minutes.
Collect: this worksheet. Quick checks: the faulty flowchart fails at 04:00 (outputs RED instead of AMBER) and 07:00 (outputs GREEN instead of AMBER); fixed Diamond D2 is level >= 3.2 AND rain >= 15; fixed Diamond D3 is level >= 2.4.
An automated sensor on Pont Glyn bridge measures the height of the Afon Glyn (level, in metres) and the rainfall rate (rain, in mm/hr) every hour. During last night’s storm, a trainee programmer’s flowchart triggered a false village evacuation at 04:00 and missed a real flood warning at 07:00. You will trace the faulty flowchart to prove why it failed, correct both decision diamonds, and write the fixed rules in pseudocode.
AND is true only when both parts are true; OR is true when at least one part is true.< (less than), > (greater than), <= (less than or equal to), >= (greater than or equal to).level = 2.4) to check whether < or >= works properly.Follow the trainee’s flowchart in section 2 of the stimulus sheet exactly as it is written for all 8 hourly readings. Write Yes, No, or a dash (-) if a diamond is not reached. In the last column, use the official specification in section 1 to write what the alert should have been, then circle the two hours where the outputs do not match.
| Time | level (m) | rain (mm/hr) | D1:level < 2.0? |
D2:level >= 3.2 OR rain >= 15? |
D3:level < 2.4? |
Faulty output | Expected output (spec) |
|---|---|---|---|---|---|---|---|
| 01:00 | 1.4 | 2 | Yes | - | - | GREEN | GREEN |
| 02:00 | 1.7 | 5 | |||||
| 03:00 | 1.9 | 11 | |||||
| 04:00 | 2.6 | 18 | |||||
| 05:00 | 3.3 | 19 | |||||
| 06:00 | 3.4 | 16 | |||||
| 07:00 | 2.8 | 9 | |||||
| 08:00 | 1.8 | 3 |
Complete the bug report below for Diamonds D2 and D3.
| Diamond | Faulty condition | Why it caused a wrong alert (quote the hour and numbers) | Corrected condition |
|---|---|---|---|
| Diamond D2 (Red check) |
level >= 3.2 OR rain >= 15 |
||
| Diamond D3 (Amber check) |
level < 2.4 |
Trace these 5 test cases through your corrected flowchart to prove that your fix works, including two boundary tests right on the 2.0 m and 2.4 m thresholds.
| Test case | level (m) | rain (mm/hr) | D1:level < 2.0? |
Fixed D2:level >= 3.2 AND rain >= 15? |
Fixed D3:level >= 2.4? |
Fixed output |
|---|---|---|---|---|---|---|
| 04:00 storm shower | 2.6 | 18 | ||||
| 06:00 peak flood | 3.4 | 16 | ||||
| 07:00 high river | 2.8 | 9 | ||||
| Boundary test A | 2.4 | 10 | ||||
| Boundary test B | 2.2 | 10 |
(a) Complete the pseudocode for the fixed Pont Glyn flood alert algorithm using IF, ELSE IF, ELSE and END IF.
INPUT level, rain
IF level < 2.0 THEN
OUTPUT "GREEN: Normal"
ELSE IF ____________________________________________________ THEN
OUTPUT "__________________________________________"
ELSE IF ____________________________________________________ THEN
OUTPUT "__________________________________________"
ELSE
OUTPUT "__________________________________________"
END IF
(b) Explain why the program must check the RED condition (level >= 3.2 AND rain >= 15) before it checks the AMBER condition (level >= 2.4).
AND, OR, < and >=.AND and OR and why OR caused a false evacuation at 04:00.< vs >=) and test it with boundary data.IF / ELSE IF / ELSE pseudocode algorithm in the right order.level >= 3.8, regardless of whether it is still raining. Explain where in your IF / ELSE IF chain this new check must be placed and write the updated pseudocode.