Cambridge International Advanced Subsidiary and Advanced Level
Cambridge International Advanced Subsidiary and Advanced Level
Cambridge International Advanced Subsidiary and Advanced Level
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (NF/JG) 146141/3
© UCLES 2018 [Turn over
2
1 (a) A farm has a number of greenhouses used to grow vegetables. Each greenhouse has a
different identification number. A program is needed to store temperature information for each
greenhouse throughout the day.
Variable Value
Mark 60
Subject "Computer Science"
Grade 'B'
CourseCompleted TRUE
AverageMark 49.5
For the built-in functions list, refer to the Appendix on page 16.
Expression Evaluates to
"Fas" & MID(Subject, 6, 3)
LEFT(Mark, 1)
10 + ASC(Grade)
MOD(AverageMark * 2, 3)
Give an appropriate data type for each of these variables from part (b)(i).
Subject
Grade
CourseCompleted
AverageMark
[5]
(a) (i) This pseudocode includes features that make it easier to read and understand.
Feature 1 ...........................................................................................................................
Feature 2 ...........................................................................................................................
[2]
(ii) State two additional features that should be used to make this pseudocode easier to
read and understand.
Feature 1 ...........................................................................................................................
Feature 2 ...........................................................................................................................
[2]
(b) Study the function CountDigits(). Identify the features of the function in the following
table.
Feature Answer
(c) (i) There is a mistake in the pseudocode that would produce a data type mismatch error if a
programmer were to write similar program code.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
3 A chocolate factory produces bars of chocolate. A computer program controls the process.
The weight of each bar is stored in an array, BarWeight. The array contains 100 elements,
representing the weights of 100 bars that make up one shipping box.
1. examine each array element and count how many times the weight has exceeded MaxWeight
2. compare the count obtained with a limit value, Threshold. Call procedure ServiceCheck()
if the count exceeds the Threshold
3. output a message if the count does not exceed the Threshold. For example:
"ShippingBox OK – maximum weight exceeded 3 times."
Draw a program flowchart on the next page to represent the algorithm for the CheckWeight()
procedure.
Assume that:
• the array contains 100 valid weight values and the first element is BarWeight[1]
• MaxWeight, Threshold and BarWeight are global variables.
[10]
© UCLES 2018 9608/22/M/J/18 [Turn over
8
4 The structure chart shows part of the design of a program for an online shopping system.
Process basket
B
A E
C F
D
G
(ii) The parameters A to G shown on the chart will be used to pass the following information.
PaymentDetails
Quantity
BasketID
DeliveryAddress
ItemID
Complete the following table to show the parameter and the information it represents.
Parameter Information
G
[3]
5 A golf club holds information about its members. When a member completes a round of golf, their
score is stored along with their membership number and the date of the round.
A program is to be written to store and process the score information. The information to be stored
is formed into a string as follows:
<MembershipNumber><Date><Score>
(a) The program designer considers storing the strings in either a 1D array, RoundScore or
as a separate variable for each round, for example, RoundScore01, RoundScore02,
RoundScore03 and so on.
Describe two advantages of storing the strings in a 1D array rather than as separate variables.
Advantage 1 .............................................................................................................................
...................................................................................................................................................
Advantage 2 .............................................................................................................................
...................................................................................................................................................
[2]
(b) A procedure, AddNewScores() is being developed. The procedure will be coded using
an Integrated Development Environment (IDE).
Name two features provided by an IDE that assist in the initial detection of errors in the
procedure.
Feature 1 ..................................................................................................................................
...................................................................................................................................................
Feature 2 ..................................................................................................................................
...................................................................................................................................................
[2]
(c) The program needs a function, GetNumber(), to return a valid membership number. A valid
membership number is a four-digit numeric string between “1111” and “9999”.
The structured English representing the algorithm for this function is as follows:
MembershipNumber GetNumber()
Visual Basic and Pascal: You should include the declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [4]
© UCLES 2018 9608/22/M/J/18 [Turn over
12
(d) The program designer decides to store the strings from part (a) in a text file,
ScoreDetails.txt
<MembershipNumber><Date><Score>
Assume that there is at least one string stored for each member.
Visual Basic and Pascal: You should include the declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................ [10]
6 (a) Individual elements in a 1D array are referenced using an integer value that is used as the
subscript to the array.
Give the technical terms for the minimum and maximum values the subscript may take.
(b) A 2D array, Picture, contains data representing a bitmap image. Each element of the array
represents one pixel of the image. The image is grey-scale encoded where the value of each
pixel ranges from 0 (representing black) to 255 (representing white) with intermediate values
representing different levels of grey.
A graphics program needs a procedure, Flip(), to flip (reflect) the image. An example of an
image before and after the function is:
The values contained in the 2D array before the flip are as follows:
Data values
80 80 255 80 80 255 80 80
80 80 255 80 80 255 80 80
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [8]
Appendix
Operators (pseudocode)
Operator Description
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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.