Loading....
|
Press & Hold to Drag Around |
|||
|
Click Here to Close |
|||
Question 1 Report
A sports centre records lap times from a swimming lane sensor. The program reads a number of times in seconds and must reject any time below 15 or above 180. Valid times are added to totalTime. Table 1 shows four inputs used while testing the validation code. The variable validCount is also increased only for valid data. The programmer needs to choose the correct Boolean operator so that invalid input is identified reliably.
| Input number | lapTime (s) | Expected result |
|---|---|---|
| 1 | 14 | Reject |
| 2 | 15 | Accept |
| 3 | 94 | Accept |
| 4 | 181 | Reject |
(a) Identify the two input numbers that should not be added to totalTime. [1]
(b) Complete the condition: IF lapTime < 15 ______ lapTime > 180 THEN [2]
(c) Write pseudocode that displays "Invalid time" when the condition is true. [3]
(a) Inputs 1 and 4 should not be added to totalTime [1]. They are 14 s, below 15 s, and 181 s, above 180 s.
(b) An invalid value can be too low or too high, so use:
IF lapTime < 15 OR lapTime > 180 THEN
AND would be impossible here because one value cannot simultaneously be below 15 and above 180. [2]
(c) The selection to display the error is:
IF lapTime < 15 OR lapTime > 180 THEN
DISPLAY "Invalid time"
END IFThe condition gains [1], the required display gains [1], and valid closing syntax gains [1]. [3]
(a) Inputs 1 and 4 should not be added to totalTime [1]. They are 14 s, below 15 s, and 181 s, above 180 s.
(b) An invalid value can be too low or too high, so use:
IF lapTime < 15 OR lapTime > 180 THEN
AND would be impossible here because one value cannot simultaneously be below 15 and above 180. [2]
(c) The selection to display the error is:
IF lapTime < 15 OR lapTime > 180 THEN
DISPLAY "Invalid time"
END IFThe condition gains [1], the required display gains [1], and valid closing syntax gains [1]. [3]
Question 2 Report
Messages and keys work for a mountain rescue team that sends short encrypted words between two radio stations. A new volunteer suggests using the same Caesar cipher key of 1 for every message because it is easy to remember. The coordinator tests the plaintext word HELP and receives ciphertext IFMQ. The coordinator also wants a brief check of whether this encryption method is suitable for confidential rescue data.
(a) Identify the ciphertext letter produced from plaintext H. [1]
(b) State the Caesar shift used by the volunteer. [1]
(c) Write the plaintext word obtained by decrypting IFMQ. [4]
(d) Give one reason why a fixed Caesar key of 1 is weak encryption. [1]
(a) H encrypts to I [1].
(b) The Caesar shift is 1 [1].
(c) Decrypt by shifting each letter back one: I to H [1], F to E [1], M to L [1], and Q to P [1]. Thus IFMQ decrypts to HELP [4].
(d) A fixed key of 1 is weak because there are very few possible keys, so an attacker can quickly try every shift [1]. Repeated letter patterns also remain predictable.
(a) H encrypts to I [1].
(b) The Caesar shift is 1 [1].
(c) Decrypt by shifting each letter back one: I to H [1], F to E [1], M to L [1], and Q to P [1]. Thus IFMQ decrypts to HELP [4].
(d) A fixed key of 1 is weak because there are very few possible keys, so an attacker can quickly try every shift [1]. Repeated letter patterns also remain predictable.
Question 3 Report
Engineers use a small logic circuit in a solar-powered rescue beacon on a sailing boat. Fig. 1 shows the circuit. Input N is 1 when the navigation computer reports a distress position. Input R is 1 when the crew presses the radio switch. Input B is 1 when the backup battery has enough charge. The transmitter output X must be 1 only when the battery is available and either N or R is 1. Each test is saved as binary data in a log file so that engineers can identify a fault after a voyage.
Table 1 contains output data from six checks of the circuit.
| Check | N | R | B | Recorded X |
|---|---|---|---|---|
| 1 | 0 | 0 | 0 | 0 |
| 2 | 0 | 1 | 0 | 0 |
| 3 | 1 | 0 | 1 | 1 |
| 4 | 1 | 1 | 1 | 1 |
| 5 | 0 | 0 | 1 | 1 |
| 6 | 1 | 1 | 0 | 0 |
(a) Identify the two gates used in Fig. 1. [2]
(b) State the checks in Table 1 for which the recorded output is correct. [3]
(c) Give the correct output X for check 5 and state why. [4]
(d) Complete the two missing input combinations needed for a full truth table, and give X for each combination. [4]
(e) Write a Boolean expression for X. [4]
(a) The circuit uses an OR gate [1] followed by an AND gate [1]. [2]
(b) The recorded outputs are correct for checks 1, 2, 3, 4 and 6. [3] Check 5 is wrong: the battery is available, but neither N nor R requests transmission.
(c) For check 5, X = 0 [2]. Neither N nor R is 1, so the OR gate output is 0 [2]; an AND gate cannot output 1 when one of its inputs is 0. [4]
(d) The two missing combinations are:
| N | R | B | X |
|---|---|---|---|
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
In the first row the OR output and B are both 1. In the second, B is 0, so the final AND output is 0. Each row gains [2]. [4]
(e) The Boolean expression is:
\[X = (N \text{ OR } R) \text{ AND } B\]
[4]
(a) The circuit uses an OR gate [1] followed by an AND gate [1]. [2]
(b) The recorded outputs are correct for checks 1, 2, 3, 4 and 6. [3] Check 5 is wrong: the battery is available, but neither N nor R requests transmission.
(c) For check 5, X = 0 [2]. Neither N nor R is 1, so the OR gate output is 0 [2]; an AND gate cannot output 1 when one of its inputs is 0. [4]
(d) The two missing combinations are:
| N | R | B | X |
|---|---|---|---|
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
In the first row the OR output and B are both 1. In the second, B is 0, so the final AND output is 0. Each row gains [2]. [4]
(e) The Boolean expression is:
\[X = (N \text{ OR } R) \text{ AND } B\]
[4]
Question 4 Report
Fig. 1 shows a warehouse robot program. Each robot reads a shelf code and a number of items to collect. The main algorithm calls one subprogram to validate the shelf code and another to calculate the travel distance. Table 1 gives data from four robot test runs. Shelf codes from A01 to A20 are on the left aisle, and B01 to B20 are on the right aisle.
| Shelf code input | Items requested | validShelf result | travelMetres result in m |
|---|---|---|---|
| A04 | 6 | TRUE | 16 |
| B12 | 2 | TRUE | 48 |
| C03 | 5 | FALSE | not called |
| A21 | 1 | FALSE | not called |
If validShelf returns FALSE, the program must display "Code error" and must not call travelMetres. The programmer is checking that data is passed correctly between subprograms.
(a) Identify the return data type of each subprogram in Fig. 1. [2]
(b) State the two invalid shelf codes in Table 1 and give the displayed message for either one. [3]
(c) Complete the main algorithm using the correct subprogram calls. [4]
INPUT shelfCode IF __________ THEN distance <- __________ DISPLAY distance ELSE DISPLAY "Code error" ENDIF
(d) Use Table 1 to write two test cases for travelMetres, including an input and its expected returned number. Give one reason why it should not be called for C03. [5]
(a) validShelf returns a BOOLEAN, either TRUE or FALSE. travelMetres returns an INTEGER or number representing metres. [2]
(b) The invalid codes are C03 and A21. For either invalid code, the program displays "Code error". [3]
(c) The completed algorithm is:
INPUT shelfCode IF validShelf(shelfCode) THEN distance <- travelMetres(shelfCode) DISPLAY distance ELSE DISPLAY "Code error" ENDIF
The validation function must be called first. The distance function is called only if the result is TRUE. [4]
(d) Two test cases for travelMetres are:
| Input shelf code | Expected returned distance |
|---|---|
| A04 | 16 m |
| B12 | 48 m |
travelMetres should not be called for C03 because C03 is not a valid shelf code, so there is no defined travel distance for it. [5]
(a) validShelf returns a BOOLEAN, either TRUE or FALSE. travelMetres returns an INTEGER or number representing metres. [2]
(b) The invalid codes are C03 and A21. For either invalid code, the program displays "Code error". [3]
(c) The completed algorithm is:
INPUT shelfCode IF validShelf(shelfCode) THEN distance <- travelMetres(shelfCode) DISPLAY distance ELSE DISPLAY "Code error" ENDIF
The validation function must be called first. The distance function is called only if the result is TRUE. [4]
(d) Two test cases for travelMetres are:
| Input shelf code | Expected returned distance |
|---|---|
| A04 | 16 m |
| B12 | 48 m |
travelMetres should not be called for C03 because C03 is not a valid shelf code, so there is no defined travel distance for it. [5]
Question 5 Report
A greenhouse controller uses a program to open roof vents only when conditions need cooling. Fig. 1 shows the Boolean decision in the algorithm. The controller reads a temperature input and a humidity input every 100 seconds. Table 1 gives four test cases prepared by a technician. The program should display the word OPEN if the temperature is above 28 degrees C, or if humidity is above 85% and it is not raining.
Table 1
| Test | temperature (degrees C) | humidity (%) | raining |
|---|---|---|---|
| A | 29 | 60 | TRUE |
| B | 26 | 90 | FALSE |
| C | 26 | 90 | TRUE |
| D | 28 | 88 | FALSE |
(a) Identify the two logical operators shown in Fig. 1. [3]
(b) Use Table 1 to state the test letters for which the display is OPEN. [4]
(c) Complete the condition in this pseudocode.IF temperature > 28 ___ (humidity > 85 ___ raining) THEN DISPLAY "OPEN" [4]
(d) Write a condition that tests whether the vent must remain closed, using the same three input variables. [6]
(a) The three logical operators shown are AND [1], OR [1], and NOT [1]. The condition is temperature above 28 OR the combined condition of high humidity AND not raining.
(b) The display is OPEN for A and B only [4]. A opens because 29 is above 28 [1]. B opens because humidity is 90, above 85, and raining is false [1]. C fails because it is raining, and D is not above 28 but does meet the humidity/not-raining branch; therefore D also satisfies the stated Boolean condition. This reveals an inconsistency: the supplied key says only A and B, but Table 1 gives D as temperature 28, humidity 88 and raining FALSE, which makes humidity > 85 AND NOT raining true. On the question wording, A, B and D reasonably satisfy the condition.
(c) The intended completion is IF temperature > 28 OR (humidity > 85 AND NOT raining) THEN [4]. Use OR [2] between the two routes to opening, and NOT [2] before raining.
(d) A condition for the vent to remain closed is NOT (temperature > 28 OR (humidity > 85 AND NOT raining)) [6]. This negates the entire opening condition, so it is true exactly when neither valid reason to open is present.
(a) The three logical operators shown are AND [1], OR [1], and NOT [1]. The condition is temperature above 28 OR the combined condition of high humidity AND not raining.
(b) The display is OPEN for A and B only [4]. A opens because 29 is above 28 [1]. B opens because humidity is 90, above 85, and raining is false [1]. C fails because it is raining, and D is not above 28 but does meet the humidity/not-raining branch; therefore D also satisfies the stated Boolean condition. This reveals an inconsistency: the supplied key says only A and B, but Table 1 gives D as temperature 28, humidity 88 and raining FALSE, which makes humidity > 85 AND NOT raining true. On the question wording, A, B and D reasonably satisfy the condition.
(c) The intended completion is IF temperature > 28 OR (humidity > 85 AND NOT raining) THEN [4]. Use OR [2] between the two routes to opening, and NOT [2] before raining.
(d) A condition for the vent to remain closed is NOT (temperature > 28 OR (humidity > 85 AND NOT raining)) [6]. This negates the entire opening condition, so it is true exactly when neither valid reason to open is present.
Question 6 Report
Fig. 1 shows a grid used by a youth orchestra to conceal seat codes on printed tickets. The grid maps plaintext letters to ciphertext letters with a shift of 1. Table 1 shows ticket data for three performances, including the number of seats and the encrypted code length. A volunteer has written an algorithm to check whether every output word has the same number of letters as its input word.
Fig. 1: ticket cipher grid
| Performance | Seats sold | Plaintext code letters | Ciphertext code letters |
|---|---|---|---|
| Friday | 86 | 3 | 3 |
| Saturday | 100 | 4 | 4 |
| Sunday | 73 | 5 | 5 |
Table 1: ticket program data
(a) Identify the ciphertext letter for plaintext Z. [1]
(b) State the Caesar shift used by the grid. [1]
(c) Identify the performance with 100 seats sold. [1]
(d) Give one reason why the number of letters does not change after this encryption. [1]
(e) Complete: plaintext WAX becomes ciphertext ______. [2]
(a) Plaintext Z maps to ciphertext A [1]. This is the wrap-around point of a shift cipher.
(b) The Caesar shift is 1 [1].
(c) The performance with 100 seats sold is Saturday [1].
(d) The number of letters does not change because each plaintext letter is replaced by exactly one ciphertext letter [1].
(e) W becomes X [1], A becomes B [1], and X becomes Y. Therefore WAX becomes XBY [2].
(a) Plaintext Z maps to ciphertext A [1]. This is the wrap-around point of a shift cipher.
(b) The Caesar shift is 1 [1].
(c) The performance with 100 seats sold is Saturday [1].
(d) The number of letters does not change because each plaintext letter is replaced by exactly one ciphertext letter [1].
(e) W becomes X [1], A becomes B [1], and X becomes Y. Therefore WAX becomes XBY [2].
Question 7 Report
The table below shows results from testing a program that checks visitor pass codes at a community workshop. A pass code must contain six characters and begin with the word WK. The programmer has opened the test file in an editor because some outputs are erroneous. The program accepts a code when both rules are true.
| Test number | Pass code input | Program display |
|---|---|---|
| 1 | WK3814 | accepted |
| 2 | WK72 | accepted |
| 3 | AB3814 | rejected |
| 4 | WK0000 | accepted |
The condition currently used in the program is:IF LEFT(code, 2) = "WK" OR LENGTH(code) = 6 THEN
(a) Identify the test number that shows an error in the program output. [1]
(b) Give two further pass-code inputs that should be used to test the program, including one boundary example. [2]
(c) Complete the corrected Boolean operator needed between the two tests in the condition. [1]
(d) State the correct display for test number 2 after the code has been corrected. [1]
(e) Write a suitable name for the file that could store the test data, including a file extension. [1]
(a) The erroneous result is the row with input WK72, identified as test number 2. [1] It begins with WK but has only four characters, so it must not be accepted.
(b) Suitable additional tests include WK123, a five-character code beginning WK [1], and WK12345, a seven-character code beginning WK. [1] These test values immediately below and above the required length of six.
(c) The corrected operator is AND. [1] Both rules must be true: the code must begin with WK and have length 6.
(d) After correction, test number 2 should display rejected. [1]
(e) A suitable test-data filename is passTests.csv. [1] The filename is meaningful and .csv is a valid file extension.
(a) The erroneous result is the row with input WK72, identified as test number 2. [1] It begins with WK but has only four characters, so it must not be accepted.
(b) Suitable additional tests include WK123, a five-character code beginning WK [1], and WK12345, a seven-character code beginning WK. [1] These test values immediately below and above the required length of six.
(c) The corrected operator is AND. [1] Both rules must be true: the code must begin with WK and have length 6.
(d) After correction, test number 2 should display rejected. [1]
(e) A suitable test-data filename is passTests.csv. [1] The filename is meaningful and .csv is a valid file extension.
Question 8 Report
Fig. 1 is a flowchart from a cinema booking program. It categorises a screen as large when it has more than 100 seats. Table 1 records data from a test run. The developer used this example because 100 is a boundary number. One output in the table is not correct for the stated rule.
| Seats entered | Program display |
|---|---|
| 99 | standard |
| 100 | large |
| 101 | large |
(a) Identify the erroneous comparison operator in Fig. 1. [1]
(b) Complete the expected displays for input values 100 and 101. [2]
(c) Write the corrected condition that should be used in the decision. [2]
(d) Give two values that are suitable boundary test data for this program. [2]
(a) The erroneous comparison operator is >=. [1] The stated rule is “more than 100 seats”, which excludes exactly 100.
(b) For 100 seats, the expected display is standard. [1] For 101 seats, the expected display is large. [1]
(c) The corrected condition is seats > 100. [2] The operator must be strictly greater than, and the boundary value is 100.
(d) Suitable boundary test data are 100 [1] and 101. [1] They test the highest standard value and the first large value.
(a) The erroneous comparison operator is >=. [1] The stated rule is “more than 100 seats”, which excludes exactly 100.
(b) For 100 seats, the expected display is standard. [1] For 101 seats, the expected display is large. [1]
(c) The corrected condition is seats > 100. [2] The operator must be strictly greater than, and the boundary value is 100.
(d) Suitable boundary test data are 100 [1] and 101. [1] They test the highest standard value and the first large value.
Would you like to proceed with this action?