chapter4
chapter4
9 Many companies use computers to process their payroll. This involves the updating of a master
file.
Every week the master file has to be updated to insert (I) the details of new workers and to delete
(D) the details of workers who have left the company. Records also have to be amended (A) if an
existing worker’s details have changed.
Two tables are shown below. The first represents part of a transaction file containing the type of
transaction. The second represents part of the master file used by the company. This shows the
workers’ ID numbers and the job they do.
6 Six from:
REPEAT
INPUT temperature
IF temperature < preset
THEN
IF pump switched off
THEN
send signal to switch pump on
ENDIF
ELSE
IF pump switched on
THEN
send signal to switch pump off
ENDIF
ENDIF
UNTIL system switched off
1 mark for correct 1st IF statement
1 mark for correctly positioned first action
1 mark for correctly positioned 1st ENDIF
1 mark for correct 2nd IF statement
1 mark for correctly positioned second action
1 mark for correctly positioned 2nd ENDIF
1 mark for correctly positioned 3rd ENDIF
1 mark for correct UNTIL statement…1 for correct position of correct UNTIL statement
June QP12 JUNE 2022
JUNE 2022
QP12
Q7
JUNE2022 QP13
Q11
MAR 2022 QP12
Q7
7 The average (mean) of a set of numbers can be found by adding the numbers together and
dividing the resulting total by how many numbers there are in the set.
Write an algorithm in pseudocode to enter and find the average of a set of numbers using a
REPEAT…UNTIL loop. Your algorithm must work for different sets of numbers.
7 Eight from:
Input number of numbers
Initialise count
Initialise total
Loop that works involving REPEAT… UNTIL (e.g. count = n)
Input number within loop
Increment count within loop
Update total within loop
Calculation of average
output average
Possible solution could be:
INPUT n
count ← 0
total ← 0
REPEAT
INPUT number
count ← count + 1
total ← total + number
UNTIL count = n
average ← total / n
PRINT average
9 Jose has a greenhouse to grow his plants. He lives in a country which has a warm
climate so the
greenhouse does not need a heater but has microprocessor controlled windows and a
temperature
sensor.
(a) Describe how the sensor represents the temperature so the computer can read the
data.
(b) Complete this pseudocode algorithm to show the processing which takes place to
control the
temperature of the greenhouse.
WHILE system switched on
INPUT temperature
IF temperature > preset
THEN
IF window closed
THEN
9(a)
One from:
• Electrical resistance is changed/voltage is generated (depending on the temperature) (1)
• Electrical signals are generated (which are converted into values (to represent
temperature)) (1).
UNTIL .........................................................................................................................
9(a)
PROCEDURE AfterTax(WagesBeforeTax)
TaxPaid ← WagesBeforeTax * 35%
WagesAfterTax ← WagesBeforeTax - TaxPaid
ENDPROCEDURE
• PROCEDURE and Appropriate name as first statement (ignore any gaps) (1)
• WagesBeforeTax in brackets on first line (1)
• Calculations and assignments within the procedure result in the correct numerical
outcome for the question (Ignore errors with variable names, as long as it is clear which
variable is being referred to) (1)
• Sensible variable names with no gaps (WagesBeforeTax has been given, must be at
least TWO extra variables) (1)
• ENDPROCEDURE as last statement (1)
9(b)
count ← 0
INPUT NumberOfWorkers
REPEAT
• INPUT Hours, Rate (1) (Candidate may do this in two steps)
• INPUT Hours, Rate as first line/before BeforeTax is called (allow follow through) (1)
• (CALL) BeforeTax(Hours, Rate) (1)
• (CALL) AfterTax(WagesBeforeTax) (1)
• BeforeTax before WagesAfterTax (1)
• PRINT/OUTPUT WagesAfterTax (1) (Must be in correct place)
• count ← count + 1 (1) (can be anywhere)
• UNTIL count = NumberOfWorkers (1)
2022 NOV QP13
Q8
8 A teacher wishes to produce a computer program to output the grades awarded for all of
her students.
If a student scores:
• more than 60 marks, they are awarded a grade A
• 50 – 60 marks, they are awarded a grade B
• 40 – 49 marks, they are awarded a grade C
• below 40 marks, they are awarded a grade D.
The teacher has written the following algorithm before writing the program. Unfortunately,
there
are errors and some lines have been left out (omitted). She has, however, managed to
include the
correct number of ELSE statements.
Identify each error or omission and how these could be corrected. Line numbers have
been included to help you.
8
Six marks available:
• Any indication that an ENDIF is missing/needs to be added (1)
• Line 6 should be >= (1)
• Line 8 B should be in quotes//it should be ‘B’ (1)
• This only allows one student’s marks to be entered (1)
• There should be an INPUT of the number of students ... (1)
... as the 1st line/before INPUT mark (1)
• Any indication that a COUNT is required ... (1)
... Count should be initialised at the second line/3rd line (1)
• Any indication that iteration is required ... (1)
... A loop should be set up as the third statement/ after the 1st input and count has been
initialised (1)
• The count should be incremented within the loop (1)
• The loop should be closed as the last statement (1)
• Numbers between 50 and 60 would not have a grade//no B grades would be awarded (1)
Where candidate has not identified the location of the error/improvement required they can
include direct quotes from the code to make it clear to which section they are referring.
Where candidate has done so, if their answer is the corrected version of the code, award
the mark.
6
Specimen 2025
Q6
• Suitable input
• Suitable question in decision box
• Yes(Y) and No(N) in correct places (accept the question in the decision
box could be reversed to use the < sign)
• Additional flow lines added correctly
• Use of correct arrow heads
Specimen 2025
Q10
10 Write a pseudocode algorithm, using a REPEAT … UNTIL loop, that allows eight
numbers to be entered and which will then display the smallest number.