Cambridge International AS & A Level: Computer Science 9618/41
Cambridge International AS & A Level: Computer Science 9618/41
Cambridge International AS & A Level: Computer Science 9618/41
2 hours 30 minutes
evidence.doc
INSTRUCTIONS
● Carry out every instruction in each task.
● Save your work using the file names given in the task as and when instructed.
● You must not have access to either the internet or any email system during this examination.
● You must save your work in the evidence document as stated in the tasks. If work is not saved in the
evidence document, you will not receive marks for that task.
● You must use a high‑level programming language from this list:
Java (console mode)
Python (console mode)
Visual Basic (console mode)
● A mark of zero will be awarded if a programming language other than those listed here is used.
INFORMATION
● The total mark for this paper is 75.
● The number of marks for each question or part question is shown in brackets [ ].
DC (LK) 327187
© UCLES 2023 [Turn over
2
Make sure that your name, centre number and candidate number will appear on every page of this
document. This document must contain your answers to each question.
One source file is used to answer Question 1 and two source files are used to answer Question 3.
The files are called Data.txt, AnimalData.txt and ColourData.txt
1 A program reads data from a file and searches for specific data.
(a) The main program needs to read 25 integer data items from the text file Data.txt into a
local 1D array, DataArray
Copy and paste the program code into part 1(a)(i) in the evidence document.
[1]
(ii) Amend the main program to read the contents of Data.txt into DataArray
Copy and paste the program code into part 1(a)(ii) in the evidence document.
[4]
(b) (i) The procedure PrintArray() takes an integer array as a parameter and outputs the
contents of the array in the order they are stored.
10 4 5 13 25
Copy and paste the program code into part 1(b)(i) in the evidence document.
[3]
(ii) Amend the main program to output the contents of DataArray using the procedure
PrintArray()
Copy and paste the program code into part 1(b)(ii) in the evidence document.
[1]
Copy and paste the screenshot into part 1(b)(iii) in the evidence document.
[1]
Copy and paste the program code into part 1(c) in the evidence document.
[3]
• prompt the user to input a whole number between 0 and 100 inclusive
• read and validate the input from the user
• call LinearSearch() with DataArray and the validated input value
• output the result in the format:
The number 7 is found 2 times.
Copy and paste the program code into part 1(d)(i) in the evidence document.
[4]
Copy and paste the screenshot into part 1(d)(ii) in the evidence document.
[1]
2 A computer game is being designed that will include different vehicles. A prototype for the game is
being developed using object‑oriented programming.
The class Vehicle stores data about the vehicles. Each vehicle has an identification name,
a maximum speed, a current speed and a horizontal position. The value IncreaseAmount is
added to the current speed each time the vehicle increases its speed.
Vehicle
ID : STRING stores the identification name for the vehicle
(a) (i) Write program code to declare the class Vehicle. All attributes must be private.
You only need to declare the class and its constructor. Do not declare any other methods.
If you are writing program code in Python, include attribute declarations using comments.
Copy and paste the program code into part 2(a)(i) in the evidence document.
[5]
Copy and paste the program code into part 2(a)(ii) in the evidence document.
[3]
(iii) Write program code for the set methods SetCurrentSpeed() and
SetHorizontalPosition()
Copy and paste the program code into part 2(a)(iii) in the evidence document.
[3]
Copy and paste the program code into part 2(a)(iv) in the evidence document.
[3]
(b) The child class Helicopter inherits from the parent class Vehicle. A helicopter also has a
vertical position and changes the vertical position when it increases speed.
Helicopter
VerticalPosition : INTEGER stores the vertical position
MaxHeight : INTEGER stores the maximum height the helicopter can reach
Constructor() takes the ID, maximum speed, increase amount, vertical
change and maximum height as parameters
initialises the vertical position to 0
(i) Write program code to declare the class Helicopter. You only need to declare the
class and its constructor. You do not need to declare the other methods.
Copy and paste the program code into part 2(b)(i) in the evidence document.
[5]
(ii) The Helicopter method IncreaseSpeed() overrides the method from the parent
class and:
Copy and paste the program code into part 2(b)(ii) in the evidence document.
[4]
(c) A procedure needs to output the horizontal position and speed of a vehicle. If the vehicle is a
helicopter, it also outputs the vertical position.
Copy and paste the program code into part 2(c) in the evidence document.
[3]
• instantiate a car as a new vehicle with the ID "Tiger", a maximum speed of 100 and an
increase amount of 20
• instantiate a new helicopter with the ID "Lion", a maximum speed of 350, an increase
amount of 40, a vertical change of 3 and a maximum height of 100
• call IncreaseSpeed() twice for the car and then call the output procedure from
part 2(c) for the car
• call IncreaseSpeed() twice for the helicopter and then call the output procedure from
part 2(c) for the helicopter.
Copy and paste the program code into part 2(d)(i) in the evidence document.
[5]
Copy and paste the screenshot into part 2(d)(ii) in the evidence document.
[1]
3 A program implements two stacks using 1D arrays. One stack stores the names of colours. One
stack stores the names of animals.
(a) The program contains the following global arrays and variables:
Copy and paste the program code into part 3(a) in the evidence document.
[3]
IF AnimalTopPointer = 20 THEN
RETURN FALSE
ELSE
Animal[AnimalTopPointer] DataToPush
AnimalTopPointer AnimalTopPointer + 1
RETURN TRUE
ENDIF
ENDFUNCTION
Copy and paste the program code into part 3(b)(i) in the evidence document.
[3]
IF AnimalTopPointer = 0 THEN
RETURN ""
ELSE
ReturnData Animal[AnimalTopPointer - 1]
AnimalTopPointer AnimalTopPointer - 1
RETURN ReturnData
ENDIF
ENDFUNCTION
Copy and paste the program code into part 3(b)(ii) in the evidence document.
[3]
Copy and paste the program code into part 3(b)(iii) in the evidence document.
[5]
(iv) The function PushColour() performs the same actions as PushAnimal() but inserts
an item into Colour.
The function PopColour() performs the same actions as PopAnimal() but removes
the next item from Colour.
Copy and paste the program code into part 3(b)(iv) in the evidence document.
[2]
© UCLES 2023 9618/41/M/J/23 [Turn over
10
Copy and paste the program code into part 3(b)(v) in the evidence document.
[2]
Copy and paste the program code into part 3(c) in the evidence document.
[5]
Copy and paste the program code into part 3(d)(i) in the evidence document.
[1]
Copy and paste the screenshot into part 3(d)(ii) in the evidence document.
[1]
© UCLES 2023 9618/41/M/J/23
11
BLANK PAGE
BLANK PAGE
Permission to reproduce items where third‑party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer‑related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.