Mazvita Chadzimura Form 4 Paper 2 Test 1
Mazvita Chadzimura Form 4 Paper 2 Test 1
1. A program checks that the data entered is between 1 and 100 inclusive.
Identify one piece of normal, extreme and erroneous test data for this program, and give a reason
for each.
Normal test data .....68.......................................................................................................................... ...........
Reason ....68 is normal test data because this data is well within the range of 1 and 100, and the program should be
Reason ......1 is extreme test data because this data is right on the boundary/ edge of the acceptance range however, the
Reason .....200 is erroneous test data because this data is outside the acceptable range and therefore should not be
2. The pseudocode algorithm should work as a calculator and output the result.
1 Continue 1
2 WHILE Continue = 0
3 OUTPUT "Enter 1 for +, 2 for -, 3 for * or 4 for /"
4 INPUT Operator
5 OUTPUT "Enter the first value"
6 INPUT Value1
7 OUTPUT "Enter the second value"
8 OUTPUT Value2
9 IF Operator
10 1: Answer Value1 + Value2
11 2: Answer Value1 - Value2
12 3: Answer Value1 * Value2
13 4: Answer Value1 / Value2
14 ENDCASE
15 OUTPUT "The answer is ", Value1
16 OUTPUT "Do you wish to enter more values (Yes or No)?"
17 INPUT MoreValues
18 IF MoreValues = "No"
19 THEN
20 Continue 1
21 ENDIF
22 UNTIL Continue = 0
(a) Find the five errors in the pseudocode and suggest a correction for each error.
Error 1 ..... Continue 1..............(line 1) ...........
Correction .........Continue at the start of the program should be initialize to zero (continue 0 ) ...
Correction ......This line should state OUTPUT “The answer is”, Answer.....
Correction ..........This line should state UNTIL continue = 1 to end loop.......... [5]
(b) The algorithm needs changing to allow only the numbers 1, 2, 3, or 4 to be entered for the
input variable Operator.
Write the pseudocode to perform this task and state where in the algorithm it would be
located.
Pseudocode .......Try OUTPUT "Enter 1 for +, 2 for -, 3 for * or 4 for /"
INPUT Operator
Output " One is only able to Enter 1 for +, 2 for -, 3 for * or 4 for /"
INPUT Operator.
End if....................
Location in algorithm ...In between the 4 and 5 line before Value 1 and ... [5]
3. Write an algorithm to grade marks, using either pseudocode, programming statements or a flowchart.
Range Grades
90 – 100 A*
75 – 89 A
60 – 74 B
50 – 59 C
45 – 49 D
30 – 44 E
0 – 43 U
Start
Declare Mark as integer
Case: 90 to 100
Case: 60 to 74
Output ”Your grade is a B”
Case: 50 to 59
Case: 45 to 49
Case: 30 – 44
Case: 0- 43
End Select
End
[10]
Start
Largest 0
While i < 4
Output “Enter a number”
Input number
ii+1
Endwhile
End
[5]
Start
Declare Height as integer
Declare Base as integer
Declare Area as integer
End
[5]