An automated medical refrigerator monitors the storage of temperature-sensitive vaccines across two cooling chambers. The pseudocode below is designed to assign incoming vaccine vials to these chambers.
1 SET chamber1 TO ["", "", "", "", ""]
2 SET index1 TO 0
3 SET chamber2 TO ["", "", "", "", ""]
4 SET index2 TO 0
5 SET active TO True
6 SET stored TO False
7
8 [MISSING FUNCTION HEADER]
9 BEGIN FUNCTION
10 BOOLEAN success
11 SET success TO False
12 IF (pChamber = 1) THEN
13 IF (index1 < 5) THEN
14 SET chamber1[index1] TO pVial
15 SET index1 TO index1 + 1
16 SET success TO True
17 END IF
18 ELSE
19 IF (pChamber = 2) THEN
20 IF (index2 < 5) THEN
21 SET chamber2[index2] TO pVial
22 SET index2 TO index2 + 1
23 SET success TO True
24 END IF
25 END IF
26 END IF
27 SEND "Operation status: " & success TO DISPLAY
28 RETURN (success)
29 END FUNCTION
30
31 SEND "Enter chamber number (1 or 2) and vial barcode:" TO DISPLAY
32 RECEIVE targetChamber FROM (INTEGER)KEYBOARD
33 RECEIVE vialBarcode FROM (STRING)KEYBOARD
34 [MISSING FUNCTION CALL]
The algorithm is incomplete.
stored, passing the correct arguments.Construct the pseudocode for line 8 and line 34.
29 exam-style questions on Edexcel GCSE Computer Science Subprograms, covering Built-in and user-devised subprograms, Functions versus procedures, and Global and local variables. Each one has a worked solution and a mark scheme showing where the marks go.