0% found this document useful (0 votes)
41 views5 pages

Mazvita Chadzimura Form 4 Paper 2 Test 1

This document contains 5 programming problems to test algorithms. Problem 1 asks to identify normal, extreme, and erroneous test data for a program that checks data is between 1-100. Problem 2 asks to find errors in a calculator pseudocode algorithm and suggest corrections. Problem 3 provides a grading scale and asks to write an algorithm to grade marks. Problem 4 asks to write an algorithm to accept 4 numbers and output the largest. Problem 5 asks to write an algorithm to calculate the area of a triangle.

Uploaded by

Jason
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views5 pages

Mazvita Chadzimura Form 4 Paper 2 Test 1

This document contains 5 programming problems to test algorithms. Problem 1 asks to identify normal, extreme, and erroneous test data for a program that checks data is between 1-100. Problem 2 asks to find errors in a calculator pseudocode algorithm and suggest corrections. Problem 3 provides a grading scale and asks to write an algorithm to grade marks. Problem 4 asks to write an algorithm to accept 4 numbers and output the largest. Problem 5 asks to write an algorithm to calculate the area of a triangle.

Uploaded by

Jason
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Form 4 Paper 2 Test 1 [35 Marks]

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

able to accept this data......... ...........

Extreme test data ….....1........................... ...........

Reason ......1 is extreme test data because this data is right on the boundary/ edge of the acceptance range however, the

program should still be able to accept it.......

Erroneous test data .........200............................................... ...........

Reason .....200 is erroneous test data because this data is outside the acceptable range and therefore should not be

accepted by the program ....[6]

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 ) ...

Error 2 ..... OUTPUT Value2......(line 8)........

Correction .......This line should state INPUT value2 as it is an input.........

Error 3 ...... IF Operator (line 9).......


Correction ....This line should state Select Case Operator instead of an If.....

Error 4 ... OUTPUT "The answer is ", Value1 (line15).......

Correction ......This line should state OUTPUT “The answer is”, Answer.....

Error 5 ..... UNTIL Continue = 0 .........

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

Catch if Operator > 4 & Operator< 1

OUTPUT “Input Denied”

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.

Use the following grades.

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

Output “Enter mark, please”


Input Mark

Select case mark

Case: 90 to 100

Output “Your grade is an A*”


Case: 75-89

Output “Your grade is an A”

Case: 60 to 74
Output ”Your grade is a B”
Case: 50 to 59

Output “Your grade is a C”

Case: 45 to 49

Output “ Your grade is a D”

Case: 30 – 44

Output “ Your grade is an E”

Case: 0- 43

Output “ Your grade is an U”

End Select

End

[10]

4. Write an algorithm to accept 4 numbers and output the largest.

Start

Declare number as integer


Declare i as integer
Declare largest as integer

Largest  0
While i < 4
Output “Enter a number”
Input number

If number > largest


Largest  number
End if

ii+1

Endwhile

Output “the largest numbers of the 4 was,” Largest

End

[5]

5. Write an Algorithm to calculate the area of a triangle.

Start
Declare Height as integer
Declare Base as integer
Declare Area as integer

Output “Enter value for Base,”


Input Base
Output “Enter value for Height”
Input Height

Area base/ 2 * Height

Output “The area of this triangle is,” Area

End
[5]

You might also like