Year 12 IT Holiday assignment
1. 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
[8]
2. 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.[4]
(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
4
5
6
7
8
9 UNTIL
[6]
3. 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.
1. INPUT mark
2. IF mark > 60
3. THEN
4. PRINT "A"
5. ELSE
6. IF mark < 50
7. THEN
8. PRINT B
9. ELSE
10. IF mark >= 40
THEN
PRINT "C"
11.
12.
13. ELSE
14. PRINT "D"
15. ENDIF
16. ENDIF
Identify each error or omission and how these could be corrected. Line numbers have been
included to help you.[6]
4. 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]
5. Josefine has started to draw a flowchart which inputs 10 numbers and outputs the largest
value.
Complete the flowchart by filling in the empty boxes and by placing yes and no as appropriate in
the diagram.
START
COUNT=10
MAX = 0
Input
number
Stop
[7]
6. Many companies use computers to process their payroll.
A transaction file is produced once a week. It consists of the WorkerID and HoursWorked fields.
The master file contains the WorkerID, RateOfPay and WagesSoFar fields as well as other
details.
The WagesSoFar field represents how much each worker has earned so far this year.
Each worker's wage is calculated by multiplying the HoursWorked by the RateOfPay. When the
wage for that week is calculated, it is added on to the WagesSoFar field.
Every week the master file has to be updated to include the new wage earned so far this year.
(a) Complete the following pseudocode algorithm which shows the process of updating the
master file. You can assume no other transactions are being carried out.
READ first record in transaction file
READ first record in old master file
WHILE not end of transaction file
IF transaction file WorkerID = master file WorkerID
THEN
[6]
7. Complete the flowchart below to add up 6 numbers.
Use the variable total to store the sum of the numbers and the variable count to control the
number of times the loop is repeated.
Start
INPUT
number
Stop
[7]
8. 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. [8]