Past paper – A Level Computer Science (9618)

Cambridge International AS & A Level · 9618

Computer Science · Paper 21

May/June 2025 · 9618/21/M/J/25

Questions7
Marks99
TypeWritten

Answer on paper, open each mark scheme and give yourself marks, then open the Summary.

0 / 0Answer a question to start your score.
Saved 0
Advertisement
1
9618/21/M/J/25 · Question 1May/June 2025Paper 2116 marks
Loading question…
Question text

1
A program is being developed to help the manager of a shop control the stock.
(a) An identifier table has been used during the design stage.
Complete the identifier table:
Example value
Explanation
Variable name
Data type
a category of stock
"Fruit"
that is sold in the shop
when an item was
20/02/2025
sold
12.67
the cost of an item
to indicate if an item is
TRUE
in stock
[4]
(b) A module Sales() is part of the stock control program.
The table contains pseudocode extracts from the module Sales()
Each extract may include all or part of:
•
assignment
•
selection
•
iteration (repetition).
Complete the table by placing one or more ticks (✓) in each row:
Pseudocode extract
Assignment
Selection
Iteration
CalculateTotal()
Result
WHILE IsClosed
REPEAT
INPUT Value
UNTIL Sales[4] > Value
IF Sales[Current] <= 150 THEN
TRUE
Discount
ENDIF
CASE OF Option
[5]
ĬÕĊ®Ġ´íÈõÏĪÅĊÞú¸þ×
,
,
(c) Decomposition has been used to design the program to help the shop manager control the
stock.
Describe decomposition.
…
…
…
…
…
… [3]
Ĭ×Ċ®Ġ´íÈõÏĪÅĊÞü¸þ×

2
9618/21/M/J/25 · Question 2May/June 2025Paper 2110 marks
Loading question…
Question text

2
A program is being developed to calculate the pay of employees working for a company.
A function CalculateBonus() calculates bonus pay based on the value of sales.
Bonus pay is calculated as shown in the table.
Value of sales
Bonus pay
(in dollars)
(in dollars)
below 2000
0
between 2000 and 4000 inclusive
10
above 4000
100
A flowchart for the function CalculateBonus() has been designed.
START
Set BonusPay to 0
INPUT
ValueOfSales
Is
NO
ValueOfSales
> 4000 ?
YES
Is
NO
ValueOfSales
Set BonusPay to 10
> = 2000 ?
YES
Set BonusPay to 100
RETURN BonusPay
END
ĬÕĊ®Ġ´íÈõÏĪÅĊàú¸Ā×
,
,
(a) The flowchart contains logic errors.
One logic error is that BonusPay will not be set to 10 although the ValueOfSales input is
between 2000 and 4000 inclusive.
(i)
Explain why this error occurs.
…
… [1]
(ii)
Explain how this error could be corrected.
…
… [1]
(b) There are different ways to reduce the risk of errors when developing the new program, such
as the use of constants.
(i)
State a value that could be replaced by a constant in the function CalculateBonus()
… [1]
(ii)
Explain how the use of constants helps to reduce the risk of programming errors.
…
…
…
… [2]
(iii)
One other way that can reduce the risk of errors when writing the program is the use of
library routines.
Explain how library routines can reduce the risk of programming errors.
…
… [1]
Ĭ×Ċ®Ġ´íÈõÏĪÅĊàü¸Ā×
,
,
(c) All the logic errors have been corrected, and the program has been coded.
Identify and describe two other types of error that the program could contain.
Type of error …
Description …
…
…
Type of error …
Description …
…

3
9618/21/M/J/25 · Question 3May/June 2025Paper 218 marks
Loading question…
Question text

3
A student has been asked to create a simple guessing game program. This program will generate
a random integer value between 1 and 100. It will then repeatedly prompt the user to input an
integer value until they input the randomly generated value.
The student has written a structured English description:
step 1 – randomly generate an integer value between 1 and 100 inclusive
step 2 – prompt the user to input an integer value
step 3 – output an appropriate message if the value input was too high; then repeat from step 2
step 4 – output an appropriate message if the value input was too low; then repeat from step 2
step 5 – output an appropriate message if the value input was the same value that was randomly
generated; then end the program.
Write a pseudocode algorithm from this structured English description.
Assume no input validation is needed.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [8]
ĬÛĊ®Ġ´íÈõÏĪÅĊÝúµþ×

Advertisement
4
9618/21/M/J/25 · Question 4May/June 2025Paper 2128 marks
Loading question…
Question text

4
Study the algorithm:
DECLARE Chars : ARRAY[1:4] OF CHAR
DECLARE I, J : INTEGER
DECLARE Key : CHAR
2
I
'D'
Chars[1]
'T'
Chars[2]
'H'
Chars[3]
'R'
Chars[4]
WHILE I <= 4
//Outer loop
Chars[I]
Key
I – 1
J
WHILE J >= 0 AND Chars[J] > Key
//Inner loop
Chars[J]
Chars[J + 1]
J – 1
J
ENDWHILE
Key
Chars[J + 1]
I + 1
I
ENDWHILE
(a) The outer loop structure used in the algorithm is not the most appropriate one to use.
State the type of loop structure that would be the most appropriate to use and justify why it is
the most appropriate.
Loop structure …
Justification …
…
[2]
ĬÙĊ®Ġ´íÈõÏĪÅĊßüµĀ×
,
,
(b) Complete the trace table by dry running the algorithm.
The first row has been completed.
Chars
I
Key
J
Chars[J]
[1]
[2]
[3]
[4]
2
'D'
'T'
'H'
'R'
[6]
ĬÛĊ®Ġ´íÈõÏĪÅĊßúµĀ×

5
9618/21/M/J/25 · Question 5May/June 2025Paper 217 marks
Loading question…
Question text

5
Stacks and queues are both abstract data types.
A stack uses a top-of-stack pointer to indicate the location of the last item added to the stack.
A queue uses two pointers:
•
a front pointer to indicate the location of the next item to be removed from the queue
•
a rear pointer to indicate the location of the next item to be added to the queue.
A queue can be used to reverse the items stored on a stack.
For example, if a stack contains six items:
Initial state of the stack:
top-of-stack pointer
item 6
item 5
item 4
item 3
item 2
item 1
Final state of the stack when the items have been reversed:
top-of-stack pointer
item 1
item 2
item 3
item 4
item 5
item 6
Describe how the queue could be used to reverse the items that are currently stored on the stack.
Your description must include how the pointers are used in both the stack and queue.
Assume:
•
The stack initially contains an unknown number of items.
•
The queue can store all the items currently stored on the stack.
•
The queue is initially empty.
ĬÙĊ®Ġ´íÈõÏĪÅĊÞü·þ×
,
,
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

6
9618/21/M/J/25 · Question 6May/June 2025Paper 2112 marks
Loading question…
Question text

6
A program monitors the speed of vehicles as they move around a large building site.
Each vehicle contains a sensor which reads an integer value that represents the speed of the
vehicle. The value is expected to be in the range 0 to 60 inclusive.
The sensors cannot read values less than 0.
A program module has been written to validate the values read by the sensors.
(a) A test plan is needed to fully test the module.
Complete the table. The first line has been completed for you.
Assume the sensors generate only integer values.
Type of test data
Test data value
Expected outcome
normal
36
data item is accepted
[4]
(b) Each sensor used in the system has a unique sensor ID number in the range 1 to 50.
The program that is used to monitor the speed of each vehicle reads each sensor value
every second and stores this value along with the sensor’s unique ID into a global 2D array
Reading
The global array Reading has been declared as follows:
DECLARE Reading : ARRAY[1:2000, 1:2] OF INTEGER
The array contains 4000 elements organised as 2000 rows and 2 columns.
Column 1 contains the sensor value, and column 2 contains the sensor ID.
When 2000 sensor readings have been taken, the array is full and the system stops taking
any more sensor readings until the array has been processed.
A procedure Sort() is needed to sort the array into ascending order of sensor value using
an efficient bubble sort algorithm.
ĬÙĊ®Ġ´íÈõÏĪÅĊàü·Ā×
,
,
Write efficient pseudocode for the procedure Sort()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

7
9618/21/M/J/25 · Question 7May/June 2025Paper 2118 marks
Loading question…
Question text

7
A program is being developed to implement a customer loyalty scheme for a coffee shop.
The programmer has decided that the following data items need to be stored for each customer:
Data item
Description
customer ID
a unique six-digit string
an integer value that is increased by one for every cup of coffee the
points
customer orders
When a customer visits the shop and orders coffee, the scheme operates as follows:
•
The total number of points is increased by the number of coffees ordered.
•
If just one cup of coffee is ordered and the number of points goes above 10, then:
◦
the cup of coffee they have just ordered is given to them free of charge
◦
the number of points is reduced by 11.
•
If the order is for multiple coffees and the number of points goes above 10, then:
◦
they get one coffee free of charge for every 11 points
◦
the number of points is reduced by 11 for each free coffee.
For example, the:
•
customer currently has 9 points
•
customer orders 16 cups of coffee
•
total number of points now becomes 25
•
customer gets 2 free coffees and now has 3 points left.
The programmer has defined a program module that is called every time a customer places an
order:
Module
Description
•
called with two integer parameters:
◦
the number of coffees ordered
◦
CustomerOrder()
the current number of points
•
output a suitable message giving the number of free coffees
•
return a value for the new points total.
ĬÕĊ®Ġ´íÈõÏĪÅĊßù¶Ă×
,
,
(a) Write pseudocode for module CustomerOrder()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement