Cambridge International AS & A Level: Computer Science 9618/22
Cambridge International AS & A Level: Computer Science 9618/22
Cambridge International AS & A Level: Computer Science 9618/22
* 3 0 3 3 2 5 1 8 2 6 *
2 hours
INSTRUCTIONS
● Answer all questions.
● Use a black or dark blue pen.
● Write your name, centre number and candidate number in the boxes at the top of the page.
● Write your answer to each question in the space provided.
● Do not use an erasable pen or correction fluid.
● Do not write on any bar codes.
● You may use an HB pencil for any diagrams, graphs or rough working.
● Calculators must not be used in this paper.
INFORMATION
● The total mark for this paper is 75.
● The number of marks for each question or part question is shown in brackets [ ].
● No marks will be awarded for using brand names of software packages or hardware.
● The insert contains all the resources referred to in the questions.
DC (EF/SG) 312086/3
© UCLES 2023 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1 A program calculates the postal cost based on the weight of the item and its destination.
Calculations occur at various points in the program and these result in the choice of several
possible postal costs. The programmer has built these postal costs into the program.
For example, the postal cost of $3.75 is used in the following lines of pseudocode:
(a) (i) Identify a more appropriate way of representing the postal costs.
.....................................................................................................................................
Use of constants [1]
(ii) Describe the advantages of your answer to part (a)(i) with reference to this program.
...........................................................................................................................................
Postal rates are entered once only
...........................................................................................................................................
Avoids input error
...........................................................................................................................................
Makes the program easier to understand
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
(b) The lines of pseudocode contain features that make them easier to understand.
1 ................................................................................................................................................
Comments
2 ................................................................................................................................................
Capitalised keywords
3 ................................................................................................................................................
Indentation
[3]
(c) Give the appropriate data types for the following variables:
boolean
ValidAddress ........................................................................................................................
ItemPostalCost ...................................................................................................................
real
ItemStatus ............................................................................................................................
string
[3]
2 A program stores a user’s date of birth using a variable MyDOB of type DATE.
(a) Write a pseudocode statement, using a function from the insert, to assign the value
corresponding to 17/11/2007 to MyDOB.
.............................................................................................................................................
MyDOB SETDATE(17, 11, 2007) [1]
(b) MyDOB has been assigned a valid value representing the user’s date of birth.
Write a pseudocode statement to calculate the number of months from the month of the
user’s birth until the end of the year and to assign this to the variable NumMonths.
For example, if MyDOB contains a value representing 02/07/2008, the value 5 would be
assigned to NumMonths.
NumMonths 12 - MONTH(MyDOB)
............................................................................................................................................. [2]
(c) The program will output the day of the week corresponding to MyDOB.
For example, given the date 22/06/2023, the program will output "Thursday".
An algorithm is required. An array will be used to store the names of the days of the week.
...................................................................................................................................................
Step 1 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Step 2 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Step 3 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Step 4 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[6]
© UCLES 2023 9618/22/M/J/23 [Turn over
4
3 A program stores data in a text file. When data is read from the file, it is placed in a queue.
(a) The diagram below represents an Abstract Data Type (ADT) implementation of the queue.
Each data item is stored in a separate location in the data structure. During initial design, the
queue is limited to holding a maximum of 10 data items.
0
1
2
3
4
5 Red Front of Queue Pointer
6 Green
7 Blue
8 Pink End of Queue Pointer
9
(i) Describe how the data items Orange and Yellow are added to the queue shown in the
diagram.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [4]
(ii) The following diagram shows the state of the queue after several operations have been
performed. All queue locations have been used at least once.
0 D4
1 D3 End of Queue Pointer
2 D27
3 D8
4 D33
5 D17 Front of Queue Pointer
6 D2
7 D1
8 D45
9 D60
..................................................................................................................................... [1]
(b) The design of the queue is completed and the number of locations is increased.
A function AddToQueue() has been written. It takes a string as a parameter and adds this to
the queue. The function will return TRUE if the string was added successfully.
A procedure FileToQueue() will add each line from the file to the queue. This procedure
will end when all lines have been added or when the queue is full.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
Any comparison between characters needs to be case sensitive. For example, character 'a' and
character 'A' are not identical.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
BLANK PAGE
5 A programmer has produced the following pseudocode to output the square root of the numbers
from 1 to 10.
40 REPEAT
41 CALL DisplaySqrt(Num)
42 Num Num + 1.0
43 UNTIL Num > 10
...
The program code compiles without errors, but the program gives unexpected results. These are
caused by a design error.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(b) Explain why the compiler does not identify this error.
...................................................................................................................................................
............................................................................................................................................. [1]
(c) Describe how a typical Integrated Development Environment (IDE) could be used to identify
this error.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(d) The pseudocode is converted into program code as part of a larger program.
The programmer does not want to delete the complex statement but wants to change the
statement so that it is ignored by the compiler.
...................................................................................................................................................
............................................................................................................................................. [1]
6 A procedure Square() will take an integer value in the range 1 to 9 as a parameter and output a
number square.
The boundary of a number square is made up of the character representing the parameter value.
The inside of the number square is made up of the asterisk character (*).
The pseudocode OUTPUT command starts each output on a new line. For example, the following
three OUTPUT statements would result in the outputs as shown:
OUTPUT "Hello"
OUTPUT "ginger"
OUTPUT "cat"
Resulting output:
Hello
ginger
cat
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
BLANK PAGE
7 A computer system for a shop stores information about each customer. The items of information
include name and address (both postal and email) together with payment details and order history.
The system also stores the product categories they are interested in and how they would like to be
contacted.
(a) The shop wants to add a program module that will generate emails to be sent to customers
who may be interested in receiving details of new products.
(i) State three items of information that the new module would need. Justify your choice in
each case.
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
[3]
(ii) Identify two items of customer information that would not be required by the new module.
Justify your choice in each case.
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
[2]
(b) The program includes a module to validate a Personal Identification Number (PIN). This is
used when customers pay for goods using a bank card.
The table show the inputs, outputs and states for this part of the program:
Complete the state‑transition diagram to represent the information given in the table.
S2
START
S1
Cancel | Re-prompt
[4]
© UCLES 2023 9618/22/M/J/23 [Turn over
16
8 A computer shop assembles computers using items bought from several suppliers. A text file
Stock.txt contains information about each item.
Information for each item is stored as a single line in the Stock.txt file in the format:
<ItemNum><SupplierCode><Description>
Format Comment
unique number for each item in the range
ItemNum 4 numeric characters
″0001″ to ″5999″ inclusive
The file is organised in ascending order of ItemNum and does not contain all possible values in
the range.
Module Description
OnlyAlpha() • called with a parameter of type string
(already written)
• returns TRUE if the string contains only alphabetic characters,
otherwise returns FALSE
CheckInfo() • called with a parameter of type string representing a line of item
information
• checks to see whether the item information in the string is valid
• returns TRUE if the item information is valid, otherwise returns
FALSE
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
Module Description
AddItem() • called with a parameter of type string representing valid information
for a new item that is not currently in the Stock.txt file
• creates a new file NewStock.txt from the contents of the file
Stock.txt and adds the new item information at the appropriate
place in the NewStock.txt file
As a reminder, the file Stock.txt is organised in ascending order of ItemNum and does not
contain all possible values in the range.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2023 9618/22/M/J/23
19
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(c) The program contains modules SuppExists() and CheckSupplier(). These have been
written but contain errors. These modules are called from several places in the main program
and testing of the main program (integration testing) has had to stop.
Identify a method that can be used to continue testing the main program before the errors in
these modules have been corrected and describe how this would work.
Method ......................................................................................................................................
Description ................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
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.