Constructing a full solution: decompose, draw and write

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Constructing a full solution: decompose, draw and write

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which order builds a full solution correctly?
A Abstract, decompose, draw a structure diagram, then write flowcharts or pseudocode
B Write pseudocode first, then abstract, then decompose
2. A simple login system. Which list shows its inputs, process and output?
A Inputs: access granted message. Process: display the username. Output: password typed by user
B Inputs: username and password. Process: compare with stored details. Output: access granted or denied message
3. In the login system, where would the stored usernames and passwords be placed in the decomposition?
A Storage
B Output
4. A temperature alarm checks a sensor reading. Which is the process?
A Compare the temperature with the limit
B Read the temperature from the sensor
5. Which detail can be ignored when abstracting the temperature alarm scenario?
A The temperature limit that triggers the alarm
B The colour of the sensor casing

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Inputs: username, password Process: compare with stored details Output: Access granted / denied Storage: user file AThe design was not checked against the original requirements, so errors such as a wrong limit or a missing alarm output may go unnoticed.
2IF Temp > 30 THEN OUTPUT "ALARM" ENDIF BLogin system -> Get details, Check details, Show result
3Draw a structure diagram: the top box is the whole system and the lower boxes are its sub-systems CPseudocode for the decision part of a temperature alarm sub-system
4Write pseudocode for one sub-problem as a procedure, which the main program calls DThe scenario was not decomposed into inputs, processes, outputs and storage, so the design cannot be fully checked.
5Login system: Get details, Check details, Show result (no inputs, outputs or storage listed) EPROCEDURE CheckTemp IF Temp > 30 THEN OUTPUT "ALARM" ENDIF ENDPROCEDURE
6Temperature alarm pseudocode written, but never compared with the requirement 'sound alarm if above 30' FDecomposing a simple login system into inputs, processes, outputs and storage

Definitions

abstract, decompose, draw, write

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
OUTPUT "Enter password" _____ Password
2.
Threshold _ 40 INPUT Temp
3.
CALL GetLogin ____ CheckLogin CALL ShowResult
4.
FUNCTION CheckPassword(Pw) _______ BOOLEAN RETURN Pw = StoredPassword ENDFUNCTION
5.
IF Temp _ 40 THEN OUTPUT "Alarm on" ENDIF

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A OUTPUT "Enter password"
B READ Pass
C IF Pass = Stored THEN
D OUTPUT "Welcome"
E ENDIF
Question 2
A PROCEDURE CheckTemp(Temp)
B IF Temp > 30
C OUTPUT "ALARM"
D ENDIF
E ENDPROCEDURE
Question 3
A FUNCTION Ok(P) RETURNS BOOLEAN
B Match ← P = Stored
C RETURN Match
D ENDPROCEDURE
Question 4
A Count ← 0
B WHILE Count < 3 DO
C Count ← Count - 1
D OUTPUT "Try again"
E ENDWHILE
Question 5
A Total ← 0
B FOR Day ← 1 TO 7
C OUTPUT Temp
D Total ← Total + Temp
E NEXT Day

Answer Key

Constructing a full solution: decompose, draw and write
Section A: Quick Questions
Q1
A — Abstract, decompose, draw a structure diagram, then write flowcharts or pseudocode
Q2
B — Inputs: username and password. Process: compare with stored details. Output: access granted or denied message
Q3
A — Storage
Q4
A — Compare the temperature with the limit
Q5
B — The colour of the sensor casing
Section B: Match the Pairs
Q1
Inputs: username, password Process: compare with stored details Output: Access granted / denied Storage: user file → Decomposing a simple login system into inputs, processes, outputs and storage
Q2
IF Temp > 30 THEN OUTPUT "ALARM" ENDIF → Pseudocode for the decision part of a temperature alarm sub-system
Q3
Draw a structure diagram: the top box is the whole system and the lower boxes are its sub-systems → Login system -> Get details, Check details, Show result
Q4
Write pseudocode for one sub-problem as a procedure, which the main program calls → PROCEDURE CheckTemp IF Temp > 30 THEN OUTPUT "ALARM" ENDIF ENDPROCEDURE
Q5
Login system: Get details, Check details, Show result (no inputs, outputs or storage listed) → The scenario was not decomposed into inputs, processes, outputs and storage, so the design cannot be fully checked.
Q6
Temperature alarm pseudocode written, but never compared with the requirement 'sound alarm if above 30' → The design was not checked against the original requirements, so errors such as a wrong limit or a missing alarm output may go unnoticed.
Section C: Definitions
Q1
abstract, decompose, draw, write — Abstract the scenario, split it into inputs, processes, outputs and storage, draw a structure diagram, then write a flowchart or pseudocode for each part and check it against the requirements.
Section D: Fill in the Blanks
Q1
OUTPUT "Enter password" INPUT Password
Q2
Threshold ← 40 INPUT Temp
Q3
CALL GetLogin CALL CheckLogin CALL ShowResult
Q4
FUNCTION CheckPassword(Pw) RETURNS BOOLEAN RETURN Pw = StoredPassword ENDFUNCTION
Q5
IF Temp > 40 THEN OUTPUT "Alarm on" ENDIF
Section E: Spot the Error
Q1
B — Cambridge pseudocode reads a value from the user with INPUT, not READ. The login input should be INPUT Pass.
Q2
B — An IF condition must be followed by THEN. The line should be IF Temp > 30 THEN.
Q3
D — A FUNCTION must be closed with ENDFUNCTION. ENDPROCEDURE only closes a PROCEDURE.
Q4
C — The login attempt counter must go up by 1 each time so the loop stops after 3 attempts. With - 1 it never reaches 3, so the loop never ends. It should be Count ← Count + 1.
Q5
C — The temperature is an input from the sensor, so the program must use INPUT Temp. OUTPUT would not read a value, and Total would not be calculated correctly.