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 Correction Error 2 Correction Error 3 Correction Error 4 Correction Error 5 Correction[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 Location in algorithm[5]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2021). The mark or mark type is shown in brackets.
- One mark for error identified and suggested correction (Max three)
- Line 8 OUTPUT Value2 - should be INPUT Value2
- Line 9 IF Operator – should be CASE OF Operator
- Line 15 OUTPUT "The answer is ", Value1 - should be Answer
- The loop may be corrected using a number of alternative methods:
- One mark for error identified and suggested correction (Max two)
- Method 1
- Line 1 Continue ← 1 should be Continue ← 0
- Line 22 UNTIL Continue = 0 should be ENDWHILE // Line 2 WHILE Continue = 0 should be REPEAT and Line 22 UNTIL Continue = 0 should be Until Continue = 1
- OR
- Method 2
- Line 2 WHILE Continue = 0 should be REPEAT
- Line 20 Continue ← 1 should be Continue ← 0 // Line 1 Continue ← 1 should be Continue ← 0 and Line 22 UNTIL Continue = 0 should be Until Continue = 1
- OR
- Method 3
- Line 2 WHILE Continue = 0 should be WHILE Continue = 1
- Line 20 Continue ← 1 should be Continue ← 0 and Line 22 UNTIL Continue = 0 should be ENDWHILE
- One mark per bullet
- MP1 Appropriate loop (begin and end) / otherwise selection
- MP2 Testing both ends of condition
- MP3 Suitable message
- MP4 Input/re-input
- WHILE Operator < 1 OR Operator > 4 (DO)
- OUTPUT "Enter 1, 2, 3 or 4"
- INPUT Operator
- ENDWHILE
- Alternative answer
- REPEAT
- IF Operator < 1 OR Operator > 4
- THEN
- OUTPUT "Enter 1, 2, 3 or 4"
- INPUT Operator
- ENDIF
- UNTIL Operator >= 1 AND Operator <= 4
- One mark
- After line 4 / between lines 2 and 5
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →