Further programming: paradigms, OOP, files and exceptions – A Level Computer Science (9618)

27 questions · page 1 of 2 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
1
9618/31/O/N/25 · Question 10Oct/Nov 2025Paper 313 marks
Loading question…
Question text

10 Explain what is meant by exception handling.
Include an example of a possible cause of an exception in your answer.
Explanation …
…
…
…
Example …
[3]
ĬÙú¾Ġ´íÈõÏĪÅĊàû·þ×

2
9618/32/O/N/25 · Question 10Oct/Nov 2025Paper 324 marks
Loading question…
Question text

10 An exception is an error that may cause a program to halt unexpectedly.
(a) Describe how program termination due to an exception can be avoided.
…
…
…
…
… [2]
(b) Identify two possible causes of exceptions.
1 …
…
2 …
…
[2]
ĬÓĊ®Ġ´íÈõÏĪÅĊßùµĀ×

3
9618/33/O/N/25 · Question 12Oct/Nov 2025Paper 335 marks
Loading question…
Question text

12 An exception can occur when running a program.
(a) Explain what is meant by an exception.
…
…
…
…
…
… [3]
(b) Identify one example of an exception and give one reason why the exception may cause a
problem.
Example …
…
Reason …
…
[2]
ĬÛú¾Ġ´íÈõÏĪÅĊàû¶Ā×

Advertisement
4
9618/41/O/N/25 · Question 2Oct/Nov 2025Paper 4130 marks
Loading question…
Question text

2
A program stores data about trains and train stations using Object-Oriented Programming (OOP).
The class Train stores the data about the trains:
Train
TrainIDNumber : String
stores the train ID number
Route : Integer
stores the route number the train is travelling
initialises TrainIDNumber and Route to the parameter
Constructor()
values
GetTrainIDNumber()
returns the train ID number
GetRoute()
returns the route number the train is travelling
Write program code to declare the class Train and its constructor.
(a) (i)
Do not declare the other methods.
All attributes should be private.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question2_N25.
Copy and paste the program code into part 2(a)(i) in the evidence document.
[4]
The methods GetTrainIDNumber() and GetRoute() return the appropriate attribute.
(ii)
Write program code for GetTrainIDNumber() and GetRoute()
Save your program.
Copy and paste the program code into part 2(a)(ii) in the evidence document.
[3]
(b) The program is tested with four trains:
train ID number
route
12ADV
134
33ART
20
9FKF
3
21VBC
24
Write program code to declare an instance of Train for each of the four trains.
Save your program.
Copy and paste the program code into part 2(b) in the evidence document.
[2]
(c) The class Station stores the data about the stations:
Station
StationID : String
stores the station ID
NumberPlatforms : Integer
stores the number of platforms at the station
Trains[0:9] : Train
stores the trains currently at the station platforms
NumberTrains : Integer
stores the number of trains currently at the station
platforms
initialises StationID and NumberPlatforms
Constructor()
to the parameter values, initialises Trains to an
empty array and NumberTrains to 0
GetTrains()
returns a string containing data about the trains
currently at the station platforms
takes a Train parameter and stores it if there is a
AddTrain()
platform available; each platform can only have one
train
Write program code to declare the class Station and its constructor.
(i)
Do not declare the other methods.
All attributes should be private.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program.
Copy and paste the program code into part 2(c)(i) in the evidence document.
[3]
The method AddTrain() takes a Train parameter. The method compares the
(ii)
attributes NumberTrains and NumberPlatforms to identify if there is a platform
available (a platform currently with no train).
The method returns FALSE if there are no platforms available.
If there is a platform available, the method:
•
stores the Train parameter in the array Trains
•
updates the appropriate attribute(s)
•
returns TRUE
Write program code for AddTrain()
Save your program.
Copy and paste the program code into part 2(c)(ii) in the evidence document.
[4]
The method GetTrains() returns the string "There are no trains" if there are no
(iii)
trains at the station platforms.
If there are trains at the station platforms, the method returns a string in the format:
The trains at station <StationID> are:
<TrainIDNumber> on route number <Route>
The line <TrainIDNumber> on route number <Route> is repeated for each train
at the station platforms.
For example: If the station with the station ID "NT1" has two trains with the train ID
numbers "48RTG", "6UFH", the method will produce this output:
The trains at station NT1 are:
48RTG on route number 43
6UFH on route number 12
Write program code for GetTrains()
Save your program.
Copy and paste the program code into part 2(c)(iii) in the evidence document.
[6]
(d) The program is tested with two stations:
number of
station ID
platforms
STH
2
NTH
1
Write program code to amend the main program to declare an instance of Station for
(i)
each of the two

5
9618/41/O/N/25 · Question 3Oct/Nov 2025Paper 4125 marks
Loading question…
Question text

A program stores records in the 2D array HashTable. Each record is stored at a specific index of
3
the array that is calculated using a hashing algorithm with the record’s key field.
The array has 100 × 10 elements. The hashing algorithm uses the key to generate an index
between 0 and 99 (inclusive). If two key fields generate the same index, there is a collision. Any
records that have a collision are stored in the next space in the same index.
For example: In this table two record keys generated the same hash value of 1. Four record keys
generated the same hash value of 3.
Index
0
1
2
3
4
5
…
9
0
record
1
record
record
2
3
record
record
record
record
4
…
99
The program uses Object-Oriented Programming (OOP).
(a) The class Record stores data about the records:
Record
Key : Integer
stores the integer key field for the data
Data : String
stores the string data
initialises Key and Data to its parameter values
Constructor()
The attributes Key and Data are public.
Write program code to declare the class Record and its constructor.
Use your programming language appropriate constructor.
Save your program as Question3_N25.
Copy and paste the program code into part 3(a) in the evidence document.
[2]
(b) The procedure InitialiseHashTable() initialises each element in the array to an empty
or null record.
Write program code to declare the global 2D array HashTable and the procedure
InitialiseHashTable()
Save your program.
Copy and paste the program code into part 3(b) in the evidence document.
[2]
(c) The function Hash():
•
takes an integer key field as a parameter
•
calculates and returns the hash value of the key field.
The hash value is the result from the formula: key MOD 100
Write program code for Hash()
Save your program.
Copy and paste the program code into part 3(c) in the evidence document.
[2]
(d) The procedure InsertData():
•
takes an object of type Record as a parameter
•
calculates the hash value for the parameter using the appropriate function
•
stores the parameter in the correct position in HashTable
You can assume there will be no more than 10 objects that generate the same hash value.
Write program code for InsertData()
Save your program.
Copy and paste the program code into part 3(d) in the evidence document.
[4]
(e) The file "HashTableData.txt" stores 200 key values and string data items in the format:
key,string
For example, the first row in the text file is:
528,permission
The key is 528 and the string data is "permission"
The procedure ReadData():
•
opens the text file and reads each line
•
splits each line into the key and data
•
calls InsertData() with an object containing each key and matching data.
Write program code for ReadData()
Save your program.
Copy and paste the program code into part 3(e) in the evidence document.
[5]
The function GetRecord():
(f)
•
takes an integer key field as a parameter
•
calculates the hash value for the key field using the appropriate function
•
searches the hash table for the record with the matching key field
•
returns the data for the record if the record is found
•
returns "Not found" if the record is not found.
Write program code for GetRecord()
Save your program.
Copy and paste the program code into part 3(f) in the evidence document.
[5]
(g) The main program:
•
calls InitialiseHashTable() and ReadData()
•
takes five integer key fields as input from the user
•
calls GetRecord() with each input and outputs the return value.
(i)
Write program code for the main program.
Save your program.
Copy and paste the program code into part 3(g)(i) in the evidence document.
[3]
(ii)
Test your program with the following five inputs in the order given:
528
1128
1828
1062
39
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot(s) into part 3(g)(ii) in the evidence document.
[2]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and

6
9618/42/O/N/25 · Question 1Oct/Nov 2025Paper 4228 marks
Loading question…
Question text

1
A program stores data about birds using Object-Oriented Programming (OOP).
The class Bird stores the data about the birds:
Bird
DistancePerHour : Real
stores the number of kilometres per hour (km/h) the bird
can fly (between 0.0 and 100.0 inclusive)
Species : String
stores the species of the bird, for example Pigeon
XPosition : Real
stores the current horizontal position of the bird
YPosition : Real
stores the current vertical position of the bird
Constructor()
initialises Species and DistancePerHour to the
parameter values; initialises XPosition and YPosition
to 500.0
GetPosition()
returns a string message that contains the horizontal and
vertical position of the bird
GetSpecies()
returns the species of the bird
Move()
takes a direction and number of minutes flying (between
0 and 500 inclusive) as parameters and updates the
appropriate horizontal or vertical position
Write program code to declare the class Bird and its constructor.
(a) (i)
Do not declare the other methods.
All attributes should be private.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question1_N25.
Copy and paste the program code into part 1(a)(i) in the evidence document.
[4]
The method GetSpecies() returns the species of the bird.
(ii)
Write program code for GetSpecies()
Save your program.
Copy and paste the program code into part 1(a)(ii) in the evidence document.
[2]
The method GetPosition() returns a string of the bird’s data in the format:
(iii)
"X = " & <XPosition> & " Y = " & <YPosition>
An example string for a bird is:
X = 500.0 Y = 250.0
Write program code for GetPosition()
Save your program.
Copy and paste the program code into part 1(a)(iii) in the evidence document.
[3]
(iv)
If the bird is travelling north, the vertical position increases. If the bird is travelling south,
the vertical position decreases.
If the bird is travelling east, the horizontal position increases. If the bird is travelling west,
the horizontal position decreases.
The method Move():
•
takes the direction of travel as a parameter in the form ‘N’ for north, ‘S’ for south,
‘E’ for east or ‘W’ for west
•
takes the number of minutes that the bird has been flying (to the nearest minute) as
a parameter
•
calculates the distance travelled by the bird using the formula:
distance travelled = (distance per hour / 60) * minutes flying
•
updates the vertical or horizontal position using the distance calculated.
You do not need to validate the parameters.
Write program code for Move()
Save your program.
Copy and paste the program code into part 1(a)(iv) in the evidence document.
[5]
(b) The main program creates two instances of Bird
The first bird is the species ‘Cockatiel’ and flies 71.0 km/h.
The second bird is the species ‘Macaw’ and flies 56.0 km/h.
Write program code to declare and initialise the two birds.
Save your program.
Copy and paste the program code into part 1(b) in the evidence document.
[3]
(c) (i)
The main program needs to:
•
output a message that includes the species and current X position and Y position for
each bird
•
prompt the user to select one of the birds to move and take this as an input
•
prompt the user to enter the direction the bird has been travelling and take this as
an input
•
prompt the user to enter the time to the nearest minute that the bird has been
travelling and take this as an input
•
call the appropriate method to update the chosen bird’s position
•
output an update on the bird’s new position.
Each input needs to repeat until valid data is entered. All outputs must be meaningful.
Write program code to amend the main program.
Save your program.
Copy and paste the program code into part 1(c)(i) in the evidence document.
[8]
(ii)
Test your program four times to meet these criteria:
Test 1: The Cockatiel travels north for 60 minutes.
Test 2: The Macaw travels south for 30 minutes.
Test 3:

7
9618/43/O/N/25 · Question 1Oct/Nov 2025Paper 4331 marks
Loading question…
Question text

1
A program stores data for a board game using Object-Oriented Programming (OOP). The game
has objects that are placed on the board. Each object has a string code (for example "A") and an
integer value (for example, 2).
The class BoardObject stores the data about the objects that can be placed on the board:
BoardObject
Code : String
stores the board object’s code
Value : Integer
stores the integer value of the board object
Constructor()
initialises the attributes to the parameter values
GetCode()
returns Code
GetValue()
returns Value
Write program code to declare the class BoardObject and its constructor.
(a) (i)
Do not declare the other methods.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question1_N25.
Copy and paste the program code into part 1(a)(i) in the evidence document.
[5]
The methods GetCode() and GetValue() return the appropriate attribute.
(ii)
Write program code for GetCode() and GetValue()
Save your program.
Copy and paste the program code into part 1(a)(ii) in the evidence document.
[3]
(iii)
The table shows the code and value of five board objects. The table has the variable
identifier where each of the objects are stored.
Variable
Code
Value
identifier
Object1
"A"
2
Object2
"B"
3
Object3
"C"
5
Object4
"D"
2
Object5
"E"
7
Write program code for the main program to instantiate each of the five board objects
and store them in the variables with the identifiers given.
Save your program.
Copy and paste the program code into part 1(a)(iii) in the evidence document.
[3]
(b) The board objects are placed on a board that is represented by a 0-indexed 2D array:
•
the board is a 10 x 10 grid
•
each position on the board is identified by a row and column number
•
rows are numbered 0 to 9
•
columns are numbered 0 to 9
•
board objects can be placed at a row and column position
•
each board position is initialised with an empty BoardObject, an empty BoardObject
has Code = "-" and Value = 0
For example, the element highlighted in the given board is in row 1 and column 3.
Row
Column
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
The class Board stores the data about the board and where the board objects are placed.
Board
TheBoard : ARRAY[0:9, 0:9] of BoardObject
stores the board contents as a 2D array of
10 x 10 elements of type BoardObject
Constructor()
initialises each of TheBoard elements to
an empty BoardObject with Code = "-"
and Value = 0
GetObject()
takes a row and column number as
parameters and returns the BoardObject
at the row, column position
SetObject()
takes a BoardObject, row number and
column number as parameters. Stores the
BoardObject in TheBoard at the given
row, column position
DisplayBoard()
outputs the code of each BoardObject
stored in TheBoard, one row at a time
Write program code to declare the class Board and its constructor.
(i)
Do not declare the other methods.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program.
Copy and paste the program code into part 1(b)(i) in the evidence document.
[4]
The method GetObject() takes a row number and column number as parameters.
(ii)
The method returns the BoardObject stored at the parameter position.
Write program code for GetObject()
Save your program.
Copy and paste the program code into part 1(b)(ii) in the evidence document.
[2]
The method SetObject() takes three parameters: a BoardObject, row number and
(iii)
column number.
The method stores the BoardObject parameter in the row, column position in
TheBoard
Write program code for SetObject()
Save your program.
Copy and paste the program code into part 1(b)(iii) in the evidence document.
[2]
The method DisplayBoard() outputs the Code of each BoardObject stored in
(iv)
TheBoard using GetCode()
Each row in TheBoard is output on one li

8
9618/31/O/N/24 · Question 3Oct/Nov 2024Paper 315 marks
Loading question…
Question text

3
(a) Describe circuit switching as a method of data transmission.
…
…
…
…
…
… [3]
(b) State one benefit and one drawback of circuit switching as a method of data transmission.
Benefit …
…
Drawback …
…
[2]
ĬÏĊ®Ġ´íÈõÏĪÅĊÞú¸þ×

Advertisement
9
9618/31/O/N/24 · Question 9Oct/Nov 2024Paper 316 marks
Loading question…
Question text

9
A veterinary surgery wants to create a class for individual pets.
Some of the attributes required in the class are listed in the table.
Attribute
Data type
Description
PetID
STRING
unique ID assigned at registration
PetType
STRING
type of pet assigned at registration
telephone number of owner assigned at
OwnerTelephone
STRING
registration
DateRegistered
DATE
date of registration
(a) State one reason why the attributes would be declared as PRIVATE.
…
… [1]
(b) Complete the class diagram for Pet, to include:
•
an attribute and data type for the name of the pet
•
an attribute and data type for the name of the owner
•
a method to create a Pet object and set attributes at the time of registration
•
a method to assign a pet ID
•
a method to assign the date of registration
•
a method to return the pet name
•
a method to return the owner’s telephone number.
Pet
PetID
: STRING
PetType
: STRING
OwnerTelephone
: STRING
DateRegistered
: DATE
… : …
… : …
…
…
…
…
…
[5]
ĬÓĊ®Ġ´íÈõÏĪÅĊßüµĀ×

10
9618/32/O/N/24 · Question 10Oct/Nov 2024Paper 326 marks
Loading question…
Question text

10 Objects and classes form the basic structure of Object‑Oriented Programming (OOP).
(a) Outline the structure of a class.
…
…
…
…
…
… [3]
(b) Give three differences between an object and a class.
1 …
…
…
2 …
…
…
3 …
…
…
[3]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞû¸þ×

11
9618/33/O/N/24 · Question 3Oct/Nov 2024Paper 335 marks
Loading question…
Question text

3
(a) Describe circuit switching as a method of data transmission.
…
…
…
…
…
… [3]
(b) State one benefit and one drawback of circuit switching as a method of data transmission.
Benefit …
…
Drawback …
…
[2]
ĬÏĊ®Ġ´íÈõÏĪÅĊÝû¸þ×

12
9618/33/O/N/24 · Question 9Oct/Nov 2024Paper 336 marks
Loading question…
Question text

9
A veterinary surgery wants to create a class for individual pets.
Some of the attributes required in the class are listed in the table.
Attribute
Data type
Description
PetID
STRING
unique ID assigned at registration
PetType
STRING
type of pet assigned at registration
telephone number of owner assigned at
OwnerTelephone
STRING
registration
DateRegistered
DATE
date of registration
(a) State one reason why the attributes would be declared as PRIVATE.
…
… [1]
(b) Complete the class diagram for Pet, to include:
•
an attribute and data type for the name of the pet
•
an attribute and data type for the name of the owner
•
a method to create a Pet object and set attributes at the time of registration
•
a method to assign a pet ID
•
a method to assign the date of registration
•
a method to return the pet name
•
a method to return the owner’s telephone number.
Pet
PetID
: STRING
PetType
: STRING
OwnerTelephone
: STRING
DateRegistered
: DATE
… : …
… : …
…
…
…
…
…
[5]
ĬÓĊ®Ġ´íÈõÏĪÅĊàùµĀ×

13
9618/41/O/N/24 · Question 2Oct/Nov 2024Paper 4134 marks
Loading question…
Question text

2
A computer program is designed to simulate horses doing show jumping. In show jumping, horses
jump over obstacles called fences. A horse successfully jumps a fence if it does not knock the
fence down.
The program is written using Object-Oriented Programming (OOP).
The class Horse stores data about the horses.
Horse
Name : STRING
stores the name given to the horse
MaxFenceHeight : INTEGER
stores the maximum height in cm that the horse can
jump, for example 132
PercentageSuccess : INTEGER
stores the percentage chance of a horse not knocking
down a fence, for example 70 represents a 70% chance
of jumping a fence successfully
initialises Name, MaxFenceHeight and
Constructor()
PercentageSuccess to its parameter values
GetName()
returns the name of the horse
GetMaxFenceHeight()
returns the maximum height the horse can jump
Success()
calculates and returns the percentage chance of a horse
successfully jumping a specific fence
Write program code to declare the class Horse and its constructor.
(a) (i)
Do not declare the other methods.
Use your programming language’s appropriate constructor.
All attributes must be private. If you are writing in Python, include attribute declarations
using comments.
Save your program as Question2_N24.
Copy and paste the program code into part 2(a)(i) in the evidence document.
[4]
The get methods GetName() and GetMaxFenceHeight() each return the relevant
(ii)
attribute.
Write program code for the get methods.
Save your program.
Copy and paste the program code into part 2(a)(ii) in the evidence document.
[3]
(b) The array Horses stores objects of type Horse.
(i)
The program has two horses:
•
The horse named ‘Beauty’ can jump a maximum height of 150 cm and has a success
percentage rate of 72%.
•
The horse named ‘Jet’ can jump a maximum height of 160 cm and has a success
percentage rate of 65%.
Write program code to:
•
declare the array, Horses, local to the main program with space for two Horse
objects
•
store the two horses described in the array
•
output the name of both Horse objects from the array.
Save your program.
Copy and paste the program code into part 2(b)(i) in the evidence document.
[5]
(ii)
Test your program.
Take a screenshot of the output.
Save your program.
Copy and paste the screenshot into part 2(b)(ii) in the evidence document.
[1]
(c) The class Fence stores data about the fences. Each fence has a height in cm and a risk
number.
The risk is a whole number between 1 and 5 inclusive. A risk of 1 means the fence is the
easiest type to jump. A risk of 5 means the fence is the hardest type to jump.
Fence
Height : INTEGER
stores the height of the fence in cm
the height is between 70 and 180 inclusive
Risk : INTEGER
stores the risk as a whole number between 1 and 5
inclusive
initialises Height and Risk to its parameter values
Constructor()
GetHeight()
returns the height of the fence
GetRisk()
returns the risk of the fence
Write program code to declare the class Fence, its constructor and get methods.
(i)
Use your programming language’s appropriate constructor.
All attributes must be private.
If you are writing in Python, include attribute declarations using comments.
Save your program.
Copy and paste the program code into part 2(c)(i) in the evidence document.
[4]
The array Course stores four Fence objects. The user inputs the height and risk for
(ii)
each fence, and these are validated before each fence is created.
Amend the main program to:
•
declare the local array Course
•
take as input the data for four fences from the user
•
loop the input until both the height and risk are valid for each fence
•
create an instance of Fence for each of the four valid fences and store each
instance in the array.
Save your program.
Copy and paste the program code into part 2(c)(ii) in the evidence document.
[5]
(d) The chance of a horse jumping a fence without knocking it down is calculated as follows.
If the height of the fence is more than the maxi

Advertisement
14
9618/42/O/N/24 · Question 1Oct/Nov 2024Paper 4229 marks
Loading question…
Question text

1
A computer game is designed for users to select characters. Each character can take part in a
group of events. Each group has five events. There are four types of event: jump, swim, run, drive.
The program is written using object-oriented programming.
(a) The class EventItem stores data about the events.
EventItem
EventName : STRING
stores the name of the event
Type : STRING
stores the type of event, either: jump, swim, run or drive
Difficulty : INTEGER
stores the difficulty of the event from 1 (easiest) to 5
(hardest)
Constructor()
initialises EventName, Type and Difficulty to its
parameter values
GetName()
returns the name of the event
GetDifficulty()
returns the difficulty of the event
GetEventType()
returns the type of event
Write program code to declare the class EventItem and its constructor.
(i)
Do not declare the other methods.
Use your programming language’s appropriate constructor.
All attributes must be private.
If you are writing in Python, include attribute declarations, using comments.
Save your program as Question1_N24.
Copy and paste the program code into part 1(a)(i) in the evidence document.
[4]
The get methods GetName(), GetDifficulty() and GetEventType() each return
(ii)
the relevant attribute.
Write program code for the three get methods.
Save your program.
Copy and paste the program code into part 1(a)(ii) in the evidence document.
[3]
(b) The array Group stores five objects of type EventItem.
Write program code to declare Group local to the main program.
(i)
Save your program.
Copy and paste the program code into part 1(b)(i) in the evidence document.
[1]
(ii)
One group has the following events:
Event name
Event type
Event difficulty
Bridge
jump
3
Water wade
swim
4
100 mile run
run
5
Gridlock
drive
2
Wall on wall
jump
4
Write program code to create an instance of EventItem for each of the five events, and
store them in Group.
Save your program.
Copy and paste the program code into part 1(b)(ii) in the evidence document.
[3]
(c) The class Character stores data about the characters in the game.
Each character has a skill level for each type of event. The skill level is an integer between
1 and 5 inclusive. Skill level 1 is the lowest skill level, and skill level 5 is the highest skill level.
Character
CharacterName : STRING
stores the name of the character
Jump : INTEGER
stores the character’s skill level at events of type jump
Swim : INTEGER
stores the character’s skill level at events of type swim
Run : INTEGER
stores the character’s skill level at events of type run
Drive : INTEGER
stores the character’s skill level at events of type drive
Constructor()
initialises CharacterName, Jump, Swim, Run and
Drive to its parameter values
GetName()
returns the name of the character
CalculateScore()
takes the type of event and difficulty as parameters.
Calculates and returns the chance of the character
completing the event
Write program code to declare the class Character, its constructor and get method.
Use your programming language’s appropriate constructor.
All attributes must be private.
If you are writing in Python, include attribute declarations, using comments.
Save your program.
Copy and paste the program code into part 1(c) in the evidence document.
[4]
(d) The method CalculateScore() in the Character class calculates and returns the
percentage chance of a character completing an event.
When a character’s skill level is greater than or equal to the difficulty of that event, the
percentage chance of completing the event is 100%.
When a character’s skill level is less than the difficulty of that event, the character’s skill level
is subtracted from the difficulty of that event. This difference is used to identify the percentage
chance of success using this table:
Percentage chance
Difference
of success
1
80
2
60
3
40
4
20
For example:
•
A character has a skill level of 3 for events of type run.
•
An event of type run has a difficulty level of 5
•
The

15
9618/31/O/N/23 · Question 8Oct/Nov 2023Paper 318 marks
Loading question…
Question text

8
(a) A pseudocode algorithm finds a customer account record in a random file and outputs it. The
records are stored using the user-defined data type TAccount.
TYPE TAccount
DECLARE AccountNumber : INTEGER
DECLARE LastName : STRING
DECLARE FirstName : STRING
DECLARE Address : STRING
DECLARE ContactNumber : STRING
ENDTYPE
Complete the file handling pseudocode.
The function Hash() takes the customer account number as a parameter, calculates and
returns the hash value.
DECLARE Customer : TAccount
DECLARE Location : INTEGER
DECLARE AccountFile : STRING
…
"AccountRecords.dat"
… AccountFile …
OUTPUT "Please enter an account number"
INPUT Customer.AccountNumber
Hash( … )
Location
SEEK … , Location
… AccountFile, …
OUTPUT Customer
// output customer record
CLOSEFILE AccountFile
[5]
(b) Define the term exception handling.
…
… [1]
(c) State two possible causes of an exception.
…
… [2]

Advertisement