9608 - w19 - 2 - 2 - QP Computer Science
9608 - w19 - 2 - 2 - QP Computer Science
9608 - w19 - 2 - 2 - QP Computer Science
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 (ST) 171121/3
© UCLES 2019 [Turn over
2
PROCEDURE FillTank()
Tries 1
Full ReadSensor("F1")
IF NOT Full
THEN
WHILE NOT Full AND Tries < 4
CALL TopUp()
Full ReadSensor("F1")
Tries Tries + 1
ENDWHILE
IF Tries > 3
THEN
OUTPUT "Too many attempts"
ELSE
OUTPUT "Tank now full"
ENDIF
ELSE
OUTPUT "Already full"
ENDIF
ENDPROCEDURE
(a) (i) The pseudocode includes features that make it easier to read and understand.
Feature 1 ...........................................................................................................................
Feature 2 ...........................................................................................................................
Feature 3 ...........................................................................................................................
[3]
(ii) Draw a program flowchart to represent the algorithm implemented in the pseudocode.
Variable declarations are not required in program flowcharts.
[5]
Complete the table by giving a suitable data type for each example value.
43
TRUE
− 273.16
"− 273.16"
[4]
Refer to the Appendix on page 18 for the list of built-in functions and operators.
Expression Evaluates to
MID(NUM_TO_STRING(2019), 3, 1)
INT(NUM_TO_STRING(-273.16))
INT(13/2)
[4]
2 (a) Describe the program development cycle with reference to the following:
• source code
• object code
• corrective maintenance.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(b) Give three features of an Integrated Development Environment (IDE) that can help with
initial error detection while writing the program.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
...................................................................................................................................................
[3]
3 A student is developing a program to search through a string of numeric digits to count how many
times each digit occurs. The variable InString will store the string and the 1D array Result will
store the count values.
• check each character in the string to count how many times each digit occurs
• record the count for each digit using the array
• output the count for each element of the array together with the corresponding digit.
Write pseudocode to declare the array and to initialise all elements to zero.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
Declare any variables you use. Do not implement the code as a subroutine.
Refer to the Appendix on page 18 for the list of built-in functions and operators.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
4 A program is being written to control the operation of a portable music player. One part of the
program controls the output volume.
The player has two buttons, one to increase the volume and one to decrease it. Whenever a
button is pressed, a procedure Button() is called with a parameter value representing the button
as follows:
Volume increase 10
Volume decrease 20
For example, pressing the volume increase button three times followed by pressing the volume
decrease button once would result in the calls:
The program makes use of two global variables of type INTEGER as follows:
Variable Description
VolLevel The current volume setting. This must be in the range 0 to 49.
A value that can be set to limit the maximum value of VolLevel,
in order to protect the user’s hearing.
MaxVol
A value in the range 1 to 49 indicates the volume limit.
A value of zero indicates that no volume limit has been set.
The procedure Button() will modify the value of VolLevel depending on which button has
been pressed and whether a maximum value has been set.
(a) Write pseudocode for the procedure Button(). Declare any additional variables you use.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
© UCLES 2019 9608/22/O/N/19 [Turn over
10
Fill in the gaps below to define three tests that could be carried out.
Parameter value: 10
MaxVol: ..................
Parameter value: 10
MaxVol: 34
MaxVol: 40
[6]
(i) The program for the music player has been completed. The program does not contain
any syntax errors, but testing could reveal further errors.
Identify and describe one different type of error that testing could reveal.
Type ..................................................................................................................................
Description ........................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[2]
(ii) Stub testing is a technique often used in the development of modular programs.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
5 The module headers for three modules in a program are defined in pseudocode as follows:
A fourth module, Renew(), calls the three modules in the following sequence.
Validate()
Lookup()
Update()
Draw a structure chart to show the relationship between the four modules and the parameters
passed between them.
[7]
Each line of the file contains a reference, name and date of birth for one student. All the information
is held as strings and separated by the asterisk character ('*') as follows:
<Reference>'*'<Name>'*'<Date Of Birth>
"G1234*Aleza Hilton*05062001"
The reference string may be five or eight characters in length and is unique for each student. It is
made up of alphabetic and numeric characters only.
A global 1D array, Leavers, contains the references of all students who have recently left the
school. The array consists of 500 elements of data type STRING. Unused elements contain the
empty string "".
The program is to be implemented as several modules. The outline description of three of these is
as follows:
(a) Write program code for the module SearchLeavers(). Declare any additional variables
you use.
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
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2019 9608/22/O/N/19
17
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [9]
(c) CountTimes() is to be used to count how many unused elements there are in the Leavers
array. An unused element is one that contains an empty string.
Write a statement in program code that uses CountTimes() to assign the count of unused
elements to the variable Result.
Program code
...................................................................................................................................................
............................................................................................................................................. [3]
Appendix
Built-in functions (pseudocode)
Each function returns an error if the function call is not properly formed.
Operators (pseudocode)
Operator Description
Concatenates (joins) two strings
&
Example: "Summer" & " " & "Pudding" produces "Summer Pudding"
Performs a logical AND on two Boolean values
AND
Example: TRUE AND FALSE produces FALSE
Performs a logical OR on two Boolean values
OR
Example: TRUE OR FALSE produces TRUE
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 the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.