0% found this document useful (0 votes)
28 views

chapter4

Uploaded by

faiqparh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

chapter4

Uploaded by

faiqparh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Specimen 2022

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.

(b) Payroll is an example of batch processing.


Explain why batch processing is preferred to online processing for this task.
9(a) Six from:
Read first record in transaction file
Read first record in old master file
WHILE not end of transaction file DO
IF transaction file ID number = master file ID number THEN
IF Transaction = “I” OR Transaction = ”A” THEN
Write transaction file record to new master file
ELSE read next master file record
ELSE write master file record to new master file
Read next transaction file record
ENDWHILE
Write remaining master file records to new master file
Alternative solutions are possible

9(b) Four from:


For large systems the hardware required can be cheaper to buy than that in
an online system
Batch processing can be carried out at a time when the computer would not
normally be used ...
... so a company can get more work out of the computer hardware it owns
Batch processing moves the time of processing to when the computing
resources are less busy
Batch processing requires less human supervision and input ...
... reduces the staff costs for the data operators
The transaction file can be set up when it is more convenient to the person
entering the data
Online processing is designed for continual input, processing and output
whereas there are fewer occasions for input with payroll
June 2022 qp11
Many houses in cooler countries have central heating systems. In a central heating system,
microprocessors are used to control the pump which sends water from the boiler to the individual
heaters.
Complete the pseudocode algorithm to show the processing which takes place in this
microprocessor-controlled central heating system. The algorithm must prevent attempting to
switch the pump on when it is already on and attempting to switch the pump off when it is
already
off. You may assume temperature is the variable representing the actual temperature of the
house and preset represents the required temperature of the house.
REPEAT
INPUT temperature
IF temperature < preset
THEN

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

2022 NOV QP12


9 A programmer is writing an algorithm in pseudocode to represent a company’s payroll
system.
The system calculates a worker’s wages before tax by multiplying the number of hours
worked by the rate of pay per hour. A procedure within the main algorithm representing
this could be:
PROCEDURE BeforeTax(Hours, Rate)
WagesBeforeTax Hours * Rate
ENDPROCEDURE
There are two stages involved in calculating the wages after tax:
• the amount of tax paid by the worker is calculated by multiplying the WagesBeforeTax by
the rate of tax (35%);
• the amount of tax paid is then subtracted from the WagesBeforeTax.
(a) Write a procedure for calculating the wages after tax, assuming the value of
WagesBeforeTax is passed to it.
(b) The programmer’s algorithm will use the BeforeTax() procedure and the procedure
created
in part (a) to calculate and output the wage after tax for each worker.
Complete the algorithm. The statements have been numbered to help you.
1 count 0
2 INPUT NumberOfWorkers
3 REPEAT

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.

10 One mark per bullet point to a maximum of eight marks.


• Initialisation of appropriate variables to a starting value
• Input the number
• Appropriate use of IF ... THEN ... ENDIF
• Comparison
• Increment of the count
• Loops the correct amount of times
• Initialisation and output outside the loop
• Output the smallest number
One possible example could be:
count ← 0
smallest ← 0
REPEAT
INPUT number
IF number < smallest
THEN
smallest ← number
ENDIF
count ← count + 1
UNTIL count = 8
OUTPUT smallest

JUNE 2023- QP11


Q8
JUNE 2023- QP12
Q10
Gustav has started to write an algorithm using pseudocode. It will input 6 numbers, all less
than
1000, and output the smallest value.
Complete the algorithm using pseudocode.
count 0
smallest 1000
WHILE count < 6 6 marks
June2023 QP13
Q11

11 In Ruritania these are the tax rules.


• People who earn up to $10 000 pay no tax.
• People who earn between $10 000 and $40 000 pay 20% tax on their earnings above
$10 000.
• People who earn more than $40 000:
pay $6 000 ($30 000 × 20%)
and pay 40% tax on their earnings above $40 000.
Complete this flowchart which shows how the net wage (the money earned after tax is
paid) is calculated and is output for an individual in Ruritania.

You might also like