Past paper – A Level Computer Science (old syllabus, to 2021) (9608)

Cambridge International AS & A Level · 9608

Computer Science (old syllabus, to 2021) · Paper 22

Oct/Nov 2019 · 9608/22/O/N/19

Questions6
Marks75
TypeWritten

Answer on paper, open each mark scheme and give yourself marks, then open the Summary.

0 / 0Answer a question to start your score.
Saved 0
Advertisement
1
9608/22/O/N/19 · Question 1Oct/Nov 2019Paper 2216 marks
Loading question…
Question text

1
Study the following pseudocode.
PROCEDURE FillTank()
DECLARE Tries : INTEGER
DECLARE Full : BOOLEAN
1
Tries
ReadSensor("F1")
Full
IF NOT Full
THEN
WHILE NOT Full AND Tries < 4
CALL TopUp()
ReadSensor("F1")
Full
Tries + 1
Tries
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.
State three such features.
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]
(b) (i)
Programming languages support different data types.
Complete the table by giving a suitable data type for each example value.
Example value
Data type
43
TRUE
− 273.16
"− 273.16"
[4]
(ii)
Evaluate each expression in the following table.
If an expression is invalid then write ‘ERROR’.
Refer to the Appendix on page 18 for the list of built-in functions and operators.
Expression
Evaluates to
RIGHT("Stop", 3) & LEFT("ich", 2)
MID(NUM_TO_STRING(2019), 3, 1)
INT(NUM_TO_STRING(-273.16))
INT(13/2)
[4]

2
9608/22/O/N/19 · Question 2Oct/Nov 2019Paper 226 marks
Loading question…
Question text

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
9608/22/O/N/19 · Question 3Oct/Nov 2019Paper 2211 marks
Loading question…
Question text

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.
The program will:
•
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.
(a) The array Result is a 1D array of type INTEGER.
Write pseudocode to declare the array and to initialise all elements to zero.
…
…
…
…
…
… [3]
(b) Write the pseudocode for the program.
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.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement
4
9608/22/O/N/19 · Question 4Oct/Nov 2019Paper 2217 marks
Loading question…
Question text

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:
Button
Parameter value
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:
CALL
Button(10)
//
VolLevel
increased
by
1
CALL
Button(10)
//
VolLevel
increased
by
1
CALL
Button(10)
//
VolLevel
increased
by
1
CALL
Button(20)
//
VolLevel
decreased
by
1
The program makes use of two global variables of type INTEGER as follows:
Variable
Description
The current volume setting. This must be in the range 0 to 49.
VolLevel
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.
The value of MaxVol should not be changed within the procedure.
Parameter validation is not necessary.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

5
9608/22/O/N/19 · Question 5Oct/Nov 2019Paper 227 marks
Loading question…
Question text

5
The module headers for three modules in a program are defined in pseudocode as follows:
Pseudocode module header
PROCEDURE Lookup(P4 : INTEGER, BYREF M4 : STRING)
FUNCTION Update(T4 : INTEGER) RETURNS INTEGER
FUNCTION Validate(S2 : INTEGER, P3 : STRING) RETURNS BOOLEAN
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]
Question 6 begins on the next page.

6
9608/22/O/N/19 · Question 6Oct/Nov 2019Paper 2218 marks
Loading question…
Question text

6
A text file, StudentList.txt, contains a list of information about students in a school.
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>
An example of one line from the file is:
"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 "".
A program is to be written to produce a new text file, UpdatedList.txt, containing information
only for students who are still attending the school.
The program is to be implemented as several modules. The outline description of three of these is
as follows:
Module
Outline description
•
Read each line from the file StudentList.txt
Check whether the Reference appears in the
•
array using SearchLeavers()
ProcessStudentList()
If the Reference does not appear then write the
•
line to the file UpdatedList.txt
Return the number of lines not copied.
•
•
Search for a given Reference in the array Leavers
SearchLeavers()
•
If the Reference is found, return TRUE, otherwise
return FALSE
•
Take two parameters: the name of an array and a
string.
CountTimes()
•
Count the number of elements that are the same as
the string. Return the count value.
(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.
Programming language …
Program code
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement