CTS Prep-Assessment
CTS Prep-Assessment
2. Jim is writing a program to calculate the wages of workers in a teddy bear factory.
Here is the algorithm used to calculate whether a worker should get a bonus.
State the value of Pay after this code is executed for each of the following values of WagesEarned.
3(a). A programmer has written an algorithm to output a series of numbers. The algorithm is shown below:
01 for k = 1 to 3
02 for p = 1 to 5
03 print (k + p)
04 next p
05 next k
06 m = 7
07 print m * m
i. Give the first three numbers that will be printed by this algorithm.
[1]
ii. State how many times line 03 will be executed if the algorithm runs through once.
[1]
(b). Identify two basic programming constructs that have been used in this algorithm.
[2]
(c).
[2]
ii. Identify two variables that have been used in the algorithm above.
[2]
x = 15
y = 0
while x > 0
y = y + 1
x = x – y
endwhile
print(y)
x y output
[4]
(b). A teacher researches the length of time students spend playing computer games each day.
The teacher asks students how long they spend completing homework. Students answer in minutes and hours
(for example 2 hours 15 minutes).
The teacher would like to create an algorithm that will display students’ inputs in minutes only.
Input
Output
[2]
ii. A program is created to convert hours and minutes into a total number of minutes.
function ................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
endfunction
[4]
iii. The following flowchart outputs a message depending on how long each person has spent playing
computer games.
5. A car dealership uses a computer system to record details of the cars that it has for sale. Each car has a make,
model, age and number of miles driven.
The car dealership only sells cars that have fewer than 10 000 miles and are 5 years old or less.
• ask the user to enter the number of miles and the age of a car
• validate the input to check that only sensible values that are in the given range are entered
• output True if valid data has been entered or False if invalid data has been entered.
[5]
ii. The validation routine from part (i) must be tested with normal, erroneous and boundary test data.
Miles Age
Normal
Erroneous
Boundary
[3]
END OF QUESTION PAPER