Professional Documents
Culture Documents
9608 s20 PM 22 Notice-Merged
9608 s20 PM 22 Notice-Merged
For the attention of the Exams Officer and the Computer Science
teacher.
To maintain the security of our exams, we allocate all Cambridge schools to one of six
administrative zones. Different components are offered in the different administrative
zones. The Cambridge Guide to Making Entries (available from the ‘Support Materials’
section of CIE Direct) contains details of the components that are offered in your
administrative zone. You can find out which administrative zone you are in at
www.cambridgeinternational.org/preparation.
If you discover that you have prepared candidates for the examination using an
incorrect version of the pre-release material please contact Cambridge International
immediately.
1
Cambridge International AS & A Level
PRE-RELEASE MATERIAL
* 6 4 8 7 7 3 5 4 3 2 *
This material should be given to the relevant teachers and candidates as soon as it has been
received at the centre.
INSTRUCTIONS
● You should use this material in preparation for the examination.
● You should attempt the practical programming tasks using your chosen high-level, procedural
programming language.
DC (KS) 198989
© UCLES 2020 [Turn over
2
Teachers and candidates should read this material prior to the June 2020 examination for 9608 Paper 2.
Reminders
• there will be questions on the examination paper which do not relate to this pre-release material.
• you must choose a high-level programming language from this list:
Note: A mark of zero will be awarded if a programming language other than those listed is used.
• structured English
• pseudocode
• program code
Some tasks may need one or more of the built-in function or operators listed in the Appendix at the
end of this document. There will also be a similar appendix at the end of the question paper.
Declaration of variables
The syllabus document shows the syntax expected for a declaration statement in pseudocode.
If Python is the chosen language, each variable’s identifier (name) and its intended data type must be
documented using a comment statement.
Describe a processing activity that can be represented by one main task with two or more sub-tasks.
The activity can relate to any scenario, but should include aspects of selection and iteration.
• school or college
• factory or workplace
• clubs or hobbies.
TASK 1.1
TASK 1.2
TASK 1.3
For each module, decide whether the solution should be implemented as a procedure or a function.
Declare an array to store multiple pieces of data for your activity in TASK 1. For example, a 1D array of
STRING could store the names of students in a class.
TASK 2.1
Design an algorithm to search for a specific value in the array and output the array index where the
value is found.
Consider the differences between algorithms that search for a single rather than multiple instances of
the value.
• structured English
• a program flowchart
• pseudocode.
TASK 2.2
A library maintains a list of books. The list is saved in a text file, where each line of the file represents
one book.
TASK 3.1
Consider the information that should be included in the text file other than the title and the author.
TASK 3.2
Consider that this is a text file, which means that all information will be saved in STRING format.
Consider the implications of storing numeric information, such as the number of copies of each book.
Define the format of each line of the file so that each piece of information may be easily extracted.
TASK 3.3
Design a program in pseudocode that has a menu-driven interface and will perform the following
tasks:
1. Add a new book to the text file. Include validation of the different pieces of information as
appropriate.
2. Search for books written by a given author. Output the title of any books found, or a suitable
message if no books by the given author are found.
Additional information needs to be saved for each book, such as a publication date.
An additional task is needed to create a new file from the original file. The task will prompt the user to
input the additional information for each book.
Appendix
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
© UCLES 2020 9608/22/PRE/M/J/20
7
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.
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.
DC (RW/TP) 180777/4
© UCLES 2020 [Turn over
2
BLANK PAGE
Name ........................................................................................................................................
Description ................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
Count-controlled .......................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Post-condition ...........................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
(d) Name three features provided by an Integrated Development Environment (IDE) that assist
in the coding and initial error detection stages of the program development cycle.
1 ................................................................................................................................................
2 ................................................................................................................................................
3 ................................................................................................................................................
[3]
2 (a) A structure chart is often produced as part of a modular program design. The chart shows the
hierarchy of modules and the sequence of execution.
Feature 1 ..................................................................................................................................
...................................................................................................................................................
Feature 2 ..................................................................................................................................
...................................................................................................................................................
[2]
(b) Six program modules implement part of an online shopping program. The following table
gives the modules and a brief description of each module:
Module Description
Allows the user to choose a delivery slot, select items to be added to
Shop()
the basket and finally check out
ChooseSlot() Allows the user to select a delivery time. Returns a delivery slot number
FillBasket() Allows the user to select items and add them to the basket
Completes the order by allowing the user to pay for the items. Returns
Checkout()
a Boolean value to indicate whether or not payment was successful
Search() Allows the user to search for a specific item. Returns an item reference
(i) The online shopping program has been split into sub-tasks as part of the design process.
Explain the advantages of decomposing the program into modules. Your explanation
should refer to the scenario and modules described in part (b).
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
(ii) Complete the structure chart for the six modules described in part (b).
Shop()
[6]
3 A navigation program includes a function, CheckCourse(). This function is called with a real
value, Course, and returns an integer value.
The identifier table and the program flowchart for the function are shown as follows:
START
CASE OF
Check
–20 to –1
OTHERWISE Set Adjust to 10
0
Set Adjust to 0
Alert()
1 to 20
Set Adjust to –10
RETURN Adjust
END
Write pseudocode to implement the function CheckCourse(). The pseudocode must follow the
algorithm represented by the flowchart. Declare any local variables used.
Refer to the Appendix on page 19 for a list of built-in pseudocode functions and operators.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [7]
© UCLES 2020 9608/22/M/J/20 [Turn over
8
4 (a) Mustafa has developed the following pseudocode to generate ten random integers in the
range 1 to 100.
FOR Count 1 TO 10
Rnum INT(RAND(100)) + 1
Random[Count] RNum
ENDFOR
Refer to the Appendix on page 19 for a list of built-in pseudocode functions and operators.
Rewrite the pseudocode so that there are no duplicated numbers in the list of random
numbers.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
..................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
© UCLES 2020 9608/22/M/J/20
9
(b) The changes made to the pseudocode in part (a) were as a result of changes to the program
requirement.
Give the term used to describe changes made for this reason.
............................................................................................................................................. [1]
5 A global 1D array, Contact, of type STRING is used to store a list of names and email addresses.
There are 1000 elements in the array. Each element stores one data item. The format of each
data item is as follows:
<Name>':'<EmailAddress>
For example:
"Sharma Himal:hsharma99@stlmail.com"
A function, GetName(), is part of the program that processes the array. A data item string will be
passed to the function as a parameter. The function will return the Name part. Validation is not
necessary.
(a) Use structured English to describe the algorithm for the function GetName().
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(b) (i) The array is to be sorted using an efficient bubble sort algorithm. An efficient bubble sort
reduces the number of unnecessary comparisons between elements.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [4]
(ii) A procedure, BubbleSort(), is needed to sort the 1D array Contact into ascending
order of Name using an efficient bubble sort algorithm.
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.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [8]
6 A company hires out rowing boats on a lake. The company has 17 boats numbered from 1 to 17.
Boats may be hired between 9:00 and 18:00, with a maximum hire duration of 90 minutes.
The company is developing a program to help manage and record the boat hire process.
The programmer has decided to store all values relating to hire time as strings. The program will
use a 24-hour clock format. For example:
Module Description
• Takes two parameters:
StartTime: a STRING value representing a time as described
AddTime() Duration: an INTEGER value representing a duration in minutes
• Adds the duration to the time to give a new time
• Returns the new time as a STRING
(a) (i) Write pseudocode for the module AddTime(). Assume both input parameters are valid.
Refer to the Appendix on page 19 for a built-in list of pseudocode functions and
operators.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [8]
...........................................................................................................................................
..................................................................................................................................... [1]
(iii) A run-time error is one type of error that black-box testing can reveal.
Describe one other type of error that black-box testing can reveal.
...........................................................................................................................................
..................................................................................................................................... [2]
(b) The user will input the desired start time of a hire. A new module will be written to validate the
input string as a valid time in 24-hour clock format.
The string is already confirmed as being in the format "NN:NN", where N is a numeric
character.
Give an example of suitable test data that is in this format but which is invalid. Explain your
answer.
Explanation ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
(c) Each time a boat is hired out, details of the hire are added to a text file, Hirelog.txt. Each
line of the text file corresponds to information about one hire session.
<BoatNumber><Date><AmountPaid>
The total hire amount from each boat is to be stored in a global array, Total. This array is
declared in pseudocode as follows:
Module Description
• Search through the file Hirelog.txt
GetTotals() • Extract the AmountPaid each time a boat is hired
• Store the total of AmountPaid for each boat in the array
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
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
BLANK PAGE
Appendix
Built-in functions (pseudocode)
Each function returns an error if the function call is not properly formed.
LENGTH(ThisString : STRING) RETURNS INTEGER
returns the integer value representing the length of ThisString
Example: LENGTH("Happy Days") returns 10
Operators (pseudocode)
Operator Description
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.
Published
Students did not sit exam papers in the June 2020 series due to the Covid-19 global pandemic.
This mark scheme is published to support teachers and students and should be read together with the
question paper. It shows the requirements of the exam. The answer column of the mark scheme shows the
proposed basis on which Examiners would award marks for this exam. Where appropriate, this column also
provides the most likely acceptable alternative responses expected from students. Examiners usually review
the mark scheme after they have seen student responses and update the mark scheme if appropriate. In the
June series, Examiners were unable to consider the acceptability of alternative responses, as there were no
student responses to consider.
Mark schemes should usually be read together with the Principal Examiner Report for Teachers. However,
because students did not sit exam papers, there is no Principal Examiner Report for Teachers for the June
2020 series.
Cambridge International will not enter into discussions about these mark schemes.
Cambridge International is publishing the mark schemes for the June 2020 series for most Cambridge
IGCSE™ and Cambridge International A & AS Level components, and some Cambridge O Level
components.
These general marking principles must be applied by all examiners when marking candidate answers.
They should be applied alongside the specific content of the mark scheme or generic level descriptors
for a question. Each question paper and mark scheme will also comply with these marking principles.
• the specific content of the mark scheme or the generic level descriptors for the question
• the specific skills defined in the mark scheme or in the generic level descriptors for the question
• the standard of response required by a candidate as exemplified by the standardisation scripts.
Marks awarded are always whole marks (not half marks, or other fractions).
• marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit
is given for valid answers which go beyond the scope of the syllabus and mark scheme,
referring to your Team Leader as appropriate
• marks are awarded when candidates clearly demonstrate what they know and can do
• marks are not deducted for errors
• marks are not deducted for omissions
• answers should only be judged on the quality of spelling, punctuation and grammar when these
features are specifically assessed by the question as indicated by the mark scheme. The
meaning, however, should be unambiguous.
Rules must be applied consistently e.g. in situations where candidates have not followed
instructions or in the application of generic level descriptors.
Marks should be awarded using the full range of marks defined in the mark scheme for the question
(however; the use of the full mark range may be limited according to the quality of the candidate
responses seen).
Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should
not be awarded with grade thresholds or grade descriptors in mind.
Name: Sequence
Description: Instructions / lines of code are executed in a fixed order
OR
Name: Assignment
Description: A value is given to a variable
Max 3
Max 2
Note:
Must include reference to given scenario to achieve all 3 marks - Max 2 if no
reference.
2(b)(ii) 6
Notes:
Parameter types must be as shown but ignore parameter names (if given)
Check ← INT(Deviate(Course))
Adjust ← 255
CASE OF Check
-20 to -1: Adjust ← 10
0 : Adjust ← 0
1 to 20 : Adjust ← -10
OTHERWISE CALL Alert()
ENDCASE
RETURN Adjust
ENDFUNCTION
REPEAT
Rnum ← INT(RAND(100)) + 1 // from original question
Exists ← FALSE
FOR Index ← 1 to NextNum - 1 // search for Rnum
IF Random[Index] = Rnum
THEN
Exists ← TRUE
ENDIF
ENDFOR
IF Exists = FALSE
THEN
Random[NextNum] ← Rnum // store Rnum
NextNum ← NextNum + 1 // increment index
ENDIF
UNTIL NextNum > 10
Notes:
Max 5 if statement to generate random number (as given in Q) not present or
incorrectly placed.
Alternative Solution:
Mark as follows:
1 SET Index to 1
2 SELECT the character from input parameter string at Index position
3 IF character is colon then go to 5
4 Else INCREMENT Index and repeat from 2
5 Extract a substring from the left of the parameter string (and assign this to
variable Name)
6 ...Using Index -1 for the length
7 RETURN Name
Note:
Mark points may be combined for equivalent marks
e.g a suitable structured English description of the pseudocode statement
below satisfies MP 5, 6 and 7:
5(b)(i) Description: 4
5(b)(ii) 'Pseudocode' solution included here for development and clarification of mark 8
scheme.
Programming language example solutions appear in the Appendix.
PROCEDURE BubbleSort()
DECLARE Temp : STRING
DECLARE NoSwaps : BOOLEAN
DECLARE Boundary, J : INTEGER
Boundary ← 999
REPEAT
NoSwaps ← TRUE
FOR J ← 1 TO Boundary
IF Contact[J] > Contact[J+1]
THEN
Temp ← Contact[J]
Contact[J] ← Contact[J+1]
Contact[J+1] ← Temp
NoSwaps ← FALSE
ENDIF
ENDFOR
Boundary ← Boundary - 1
UNTIL NoSwaps = TRUE
ENDPROCEDURE
Mark as follows:
StartHours ← STRING_TO_NUM(LEFT(StartTime,2))
StartMinutes ← STRING_TO_NUM(RIGHT(StartTime, 2))
Total ← (StartHours * 60) + StartMinutes + Duration
NewHours ← DIV(Total, 60)
NewMinutes ← MOD(Total, 60)
NewTime ← ""
IF NewHours < 10
THEN
NewTime ← '0' // add leading zero to hours
ENDIF
IF NewMinutes < 10
THEN
NewTime ← NewTime & '0'// add leading zero
ENDIF
RETURN NewTime
ENDFUNCTION
Note:
Accept alternative methods for calculation of NewHours and NewMinutes
Explanation:
Suitable explanation
Note:
Accept times that would also be invalid for the given scenario.
6(c) 'Pseudocode' solution included here for development and clarification of mark 8
scheme.
Programming language example solutions appear in the Appendix.
PROCEDURE GetTotals()
FOR BoatNum ← 1 TO 17
Total[BoatNum] ← 0
ENDFOR
ENDWHILE
CLOSEFILE "Hirelog.txt"
ENDPROCEDURE
Sub BubbleSort()
Dim Temp As String
Dim NoSwaps As Boolean
Dim Boundary, J As Integer
Boundary = 999
Do
NoSwaps = TRUE
For J = 1 To Boundary
If Contact(J) > Contact(J+1) Then
Temp = Contact(J)
Contact(J) = Contact(J+1)
Contact(J+1) = Temp
NoSwaps = FALSE
End If
Next
Boundary = Boundary - 1
Loop Until NoSwaps = TRUE
End Sub
Q5(b)(i): Pascal
procuedre BubbleSort()
var
Temp : String;
NoSwaps : Boolean;
Boundary, J : Integer;
Boundary := 999
repeat
begin
NoSwaps := TRUE
for J := 1 to Boundary do
begin
if Contact[J] > Contact[J+1]then
begin
Temp := Contact[J];
Contact[J] := Contact[J+1];
Contact[J+1] := Temp;
NoSwaps := FALSE;
end;
end;
Boundary := Boundary – 1
end;
until NoSwaps = TRUE;
End Sub
Q5(b)(i): Python
def BubbleSort()
# Temp : String
# NoSwaps : Boolean
# Boundary, J : Integer
Boundary = 999
NoSwaps = TRUE
Boundary = Boundary - 1
End Sub
Sub GetTotals()
For BoatNum = 1 To 17
Total(BoatNum) = 0
Next
File.Close()
End Sub
Q6(c): Pascal
procedure GetTotals()
var
BoatNum : Integer;
Paid : Real;
MyFile : testfile;
for BoatNum := 1 to 17 do
Total[BoatNum] := 0;
assignFile(MyFile, "Hirelog.txt");
reset(MyFile);
close(MyFile)
end;
Q6(c): Python
def GetTotals()
# BoatNum : Integer
# Paid : Real
# File : File Handle
# FileData : String
File.Close()
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.
DC (CJ) 188580/2
© UCLES 2020 [Turn over
2
1 ................................................................................................................................................
2 ................................................................................................................................................
[1]
(b) An algorithm may be documented using different methods. These include structured English,
a program flowchart, and pseudocode.
State what a program designer represents using one or more of these methods.
...................................................................................................................................................
............................................................................................................................................. [2]
Complete the table by giving four different data types together with an example data value
for each.
[4]
(d) Draw lines to connect each of the following computing terms with the appropriate description.
Term Description
[3]
FlagA TRUE
FlagB FALSE
FlagC TRUE
Expression Evaluates to
[2]
2 (a) The following pseudocode is an attempt to define an algorithm that takes two numbers as
input and outputs the larger of the two numbers.
DECLARE A, B : INTEGER
INPUT A
INPUT B
IF A > B
THEN
OUTPUT A
ELSE
OUTPUT B
ENDIF
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2020 9608/22/O/N/20
5
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
Use only functions and operators described in the Appendix on pages 18–19.
Expression Evaluates to
.......................... (9, 4) 2
[5]
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
...................................................................................................................................................
[3]
3 A car has the ability to detect a skid by monitoring the rate of rotation (the rotational speed) of
each wheel. If the rate of rotation of any wheel is not within 10% of the average of all four wheels,
the car skids.
• simulate real-time data acquisition, by prompting for the input of four integer values in the
range 0 to 1000 inclusive, representing the rate of rotation of each wheel
• calculate the average value
• check whether any individual value is more than 10% greater than the average or more than
10% less than the average
• return TRUE if any individual value is more than 10% greater than the average or more than
10% less than the average and FALSE otherwise
• output a suitable warning message.
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
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
(b) Give two sets of test data that could be used to test the function.
[2]
4 (a) The following structured English describes an algorithm used to count the number of odd and
even digits in an input sequence.
[7]
© UCLES 2020 9608/22/O/N/20 [Turn over
10
(b) The following pseudocode is an attempt to check whether two equal-length strings consist of
identical characters.
Refer to the Appendix on pages 18–19 for the list of built-in functions and operators.
Len1 LENGTH(String1)
RetFlag TRUE
RETURN RetFlag
ENDFUNCTION
(i) Complete the trace table below by performing a dry run of the function when it is called
as follows:
[5]
..................................................................................................................................... [1]
(iii) There is an error in the algorithm, which means that under certain circumstances, the
function will return an incorrect value.
Describe the problem. Give two test strings that would demonstrate it.
Problem .............................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
(iv) Describe the modification that needs to be made to the algorithm to correct the error.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [1]
(v) State the name given to the type of testing that makes use of a trace table.
..................................................................................................................................... [1]
(vi) State two features found in a typical Integrated Development Environment (IDE) that
may be used for debugging a program.
1 ........................................................................................................................................
2 ........................................................................................................................................
[2]
5 A hashtag is used on a social media network. A hashtag is a string consisting of a hash character
‘#’ followed by one or more alphanumeric characters.
The program will include two global arrays each containing 10 000 elements:
• A 1D array, TagString, of type STRING stores each hashtag in a single element. All unused
array elements contain an empty string ("").
• A 1D array, TagCount, of type INTEGER stores a count of the number of times each hashtag
is used. The count value at a given index relates to the element stored at the corresponding
index in the TagString array.
The contents of the two arrays will be stored in a text file Backup.txt. The format of each line of
the file is:
<Hashtag><','><Count>
For example:
"#ComputerScienceClass,978"
Module Description
InitArrays() • Initialise the arrays
• The contents of the two arrays are stored in the text file Backup.txt
Existing file contents will be overwritten
SaveArrays() • Each hashtag and count are stored in one line of the file, as in the example
above
• Unused TagString elements are not added to the file
• Returns the total number of unused TagString elements
LoadArrays()
• Values from the text file Backup.txt are stored in the two arrays
• The number of elements stored is returned
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
© UCLES 2020 9608/22/O/N/20
15
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
© UCLES 2020 9608/22/O/N/20 [Turn over
16
Module Description
• Values from the text file Backup.txt are stored in the
LoadArrays() two arrays
• The number of elements stored is returned
• each line of the file contains a string of the correct format and no validation checks are
required
• there are no more than 10 000 lines in the file.
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
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2020 9608/22/O/N/20
17
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
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
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.
Published
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge International will not enter into discussions about these mark schemes.
Cambridge International is publishing the mark schemes for the October/November 2020 series for most
Cambridge IGCSE™, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.
These general marking principles must be applied by all examiners when marking candidate answers. They should be applied alongside the
specific content of the mark scheme or generic level descriptors for a question. Each question paper and mark scheme will also comply with these
marking principles.
• the specific content of the mark scheme or the generic level descriptors for the question
• the specific skills defined in the mark scheme or in the generic level descriptors for the question
• the standard of response required by a candidate as exemplified by the standardisation scripts.
Marks awarded are always whole marks (not half marks, or other fractions).
• marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit is given for valid answers which go beyond the
scope of the syllabus and mark scheme, referring to your Team Leader as appropriate
• marks are awarded when candidates clearly demonstrate what they know and can do
• marks are not deducted for errors
• marks are not deducted for omissions
• answers should only be judged on the quality of spelling, punctuation and grammar when these features are specifically assessed by the
question as indicated by the mark scheme. The meaning, however, should be unambiguous.
Rules must be applied consistently, e.g. in situations where candidates have not followed instructions or in the application of generic level
descriptors.
Marks should be awarded using the full range of marks defined in the mark scheme for the question (however; the use of the full mark range may
be limited according to the quality of the candidate responses seen).
Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should not be awarded with grade thresholds or
grade descriptors in mind.
• Process
• Output
Example answers:
Data type Example data value
BOOLEAN FALSE
STRING "Happy"
INTEGER 18
REAL 31234.56
CHAR 'H'
DATE 10/01/2019
Each row must be a different data type together with an appropriate value
1(e) 1 mark for two rows correct, 2 marks for all rows correct. 2
Expression Evaluates to
INPUT A
REPEAT
INPUT B
UNTIL B <> A
REPEAT
INPUT C
UNTIL C <> A AND C <> B
Average ← (A + B + C) / 3
OUTPUT Average
Mark as follows:
1 Declaration of all variables used (at least A, B and C)
2 Uniqueness test on A, B and C
3 Loop(s) to repeat until three unique values have been entered
4 Calculation of average value
5 Determine the largest value
6 Output of average value and largest value
Expression Evaluates to
MID("Stepwise.",5, 4) "wise"
1.5 * LENGTH("OnePointFive") 18
NUM_TO_STRING(27.5) "27.5"
DIV(9, 4) 2
1 Subtasks make the solution more manageable // make the algorithm easier to follow
2 A subtask makes the problem easier to solve / design / program than the whole task
3 A subtask is useful when a part of the algorithm is repeated
3(a) 'Pseudocode' solution included here for development and clarification of mark scheme. 8
Programming language example solutions appear in the Appendix.
FOR Index ← 1 TO 4
REPEAT
OUTPUT "Input Rotation speed for wheel ",Index
INPUT ThisRot
UNTIL ThisRot >= 0 AND ThisRot <= 1000
Rot[Index] ← ThisRot
ENDFOR
Danger ← FALSE
FOR Index ← 1 TO 4
IF Rot[Index] > (Average * 1.1) OR Rot[Index] < (Average * 0.9)
THEN
Danger ← TRUE
ENDIF
ENDFOR
IF Danger = TRUE
THEN
OUTPUT "Skid Danger"
ENDIF
RETURN Danger
ENDFUNCTION
One of:
4(a) 7
Mark as follows:
• One mark for START and END
• One mark per area outlined
"BU" 2
2 'U' ""
1
"B" 2
"B" 3
1 'B' ""
1
""
4(b)(ii) TRUE 1
4(b)(iii) One mark for explanation of problem, one mark for test strings 2
Problem:
• The inner FOR loop removes ALL characters from String2 that match the current character from String1 and not just
one instance
Test Strings:
4(b)(iv) The inner FOR loop should only remove one instance of the character from String2 1
• Single stepping
• Breakpoints
• Variable and expressions report window
• Syntax error highlighting
ENDPROCEDURE
NumUnused ← 0
RETURN NumUnused
ENDFUNCTION
5(c) ‘Pseudocode’ solution included here for development and clarification of mark scheme. 8
Programming language example solutions appear in the Appendix.
Max 8 marks from 9 available mark points
CLOSE "Backup.txt"
RETURN ArrayIndex
ENDFUNCTION
*** End of Mark Scheme – example program code solutions follow ***
For Index = 0 To 3
Do
Console.Writeline("Enter Wheel Rotation Speed: "
ThisRot = Console.Readline()
Loop Until ThisRot >= 0 And ThisRot <= 1000
Rot(Index) = ThisRot
Next
Danger = FALSE
For Index = 0 TO 3
If Rot(Index) > (Average * 1.1) OR Rot(Index) < (Average * 0.9) Then
Danger = TRUE
End If
Next
RETURN Danger
End Function
var
Rot : array [1..4] of integer;
Average : Real;
ThisRot : Integer;
Index : Integer;
Danger : Boolean;
For Index := 1 to 4 do
begin
repeat
write('Enter rotation speed : ');
readln(ThisRot);
until (ThisRot >= 0) And (ThisRot <= 1000);
Rot[Index] := ThisRot;
end;
Danger := FALSE;
For Index := 1 to 4 do
begin
If (Rot[Index] > (Average * 1.1)) OR (Rot[Index] < (Average * 0.9)) then
Danger := TRUE;
end;
CheckSkid := Danger;
end;
def CheckSkid():
# Rot[3] As Integer
# Average As Real
# ThisRot As Integer
# Danger As Boolean
Rot = [0, 0, 0, 0]
for Index in range(0, 4):
while True:
ThisRot = float(input("Enter the rotation speed of the wheel: "))
if ThisRot >= 0 and ThisRot <= 1000:
break
Rot[Index] = ThisRot
Next
Danger = False
for Index in range(0, 4):
if Rot[Index] > (Average * 1.1) or Rot[Index] < (Average * 0.9):
Danger = True
If Danger == True:
print("Skid Danger")
else:
print("No Skid Danger")
return Danger
TagString(arrayIndex) = HashTag
CountLen = Len(fileString) – Len(HashTag) – 1
Count = CInt(Right(FileString, CountLen)) ' the count
TagCount(ArrayIndex) = Count
ArrayIndex = ArrayIndex + 1
Loop
File.Close
Return ArrayIndex
End Function
var
ArrayIndex, Index, CountLen, Count : Integer;
FileData, HashTag : String;
Backup : Textfile;
const
COMMA = ',';
begin
assignfile(Backup, 'Backup.txt');
reset(File);
TagString[ArrayIndex] := HashTag;
CountLen := length(FileData) – length(HashTag) – 1;
Count := strtoint(RightStr(FileData, CountLen)); // the count
TagCount[ArrayIndex] := Count;
ArrayIndex := ArrayIndex + 1;
end;
closefile(File);
end;
COMMA = ','
TagString[ArrayIndex] = HashTag
Count = int(FileString[Index+1:]) # the count
TagCount[ArrayIndex] = Count
ArrayIndex = ArrayIndex + 1
File.close()
return ArrayIndex
PRE-RELEASE MATERIAL
* 4 5 0 9 9 2 8 9 8 7 *
This material should be given to the relevant teachers and candidates as soon as it has been
received at the centre.
INSTRUCTIONS
● You should use this material in preparation for the examination.
● You should attempt the practical programming tasks using your chosen high-level, procedural
programming language.
DC (SLM) 220516
© UCLES 2021 [Turn over
2
Candidates and teachers should read this material prior to the November 2021 examination for 9608
Paper 2.
Reminders
• there will be questions on the examination paper which do not relate to this pre-release material.
• you must choose a high-level programming language from this list:
• Visual Basic (console mode)
• Python
• Pascal / Delphi (console mode).
Note: A mark of zero will be awarded if a programming language other than those listed is used.
• structured English
• pseudocode
• program code.
Some tasks may need one or more of the built-in functions or operators listed in the Appendix at the
end of this document. There will also be a similar appendix at the end of the question paper.
Declaration of variables
The syllabus document shows the syntax expected for a declaration statement in pseudocode.
If Python is the chosen language, each variable’s identifier (name) and its intended data type must be
documented using a comment statement.
TASK 1.1
TASK 1.2
Split the process into sub-tasks and consider the advantages of this approach.
TASK 1.3
TASK 1.4
TASK 1.5
Convert the program flowcharts into pseudocode algorithms and then into a high-level language
program.
TASK 1.6
Research the different types of errors that can occur at different stages of the program development
cycle.
TASK 1.7
Consider the advantages of modular programming using both built-in and user-defined functions.
TASK 1.8
Consider ways of testing the complete program both with and without knowledge of the underlying
program code.
Consider ways of testing the main program before all the user-defined functions have been completed.
TASK 2.1
TASK 2.2
Design and write program code to declare, initialise and output the contents of a 1D array.
Add a simple menu interface to allow the user to repeatedly select any of the previous stages and to
output the array elements.
TASK 2.3
Amend this program so that it processes the elements in the array. An example of a process is to add
up all the elements in a range and find the average value.
TASK 2.4
TASK 2.5
Describe in detail the purpose of a section of code you have not written yourself.
The computer system at a sports club maintains a log of visits by each member.
Each time a member visits the club, an entry is added to a file as follows:
The system concatenates these data items and stores them as a single line in the file.
TASK 3.1
Write pseudocode to create a text file containing log data for several visits by the sports club members.
The user will input the two strings described above and these will be concatenated and added to the
file.
TASK 3.2
TASK 3.3
Prompt the user to input the membership number and output the date of each visit by that member.
TASK 3.4
TASK 3.5
Extend the program from TASK 3.4 to present a menu to allow the user to repeatedly add a new visit
(TASK 3.2) or print the visits (TASK 3.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"
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.
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.
DC (CJ) 205021/2
© UCLES 2021 [Turn over
2
BLANK PAGE
State two types of maintenance and give a reason why each may be needed.
Type ..........................................................................................................................................
Reason .....................................................................................................................................
...................................................................................................................................................
Type ..........................................................................................................................................
Reason .....................................................................................................................................
...................................................................................................................................................
[4]
(b) State why characters need to be represented in ASCII or Unicode before they can be
processed.
...................................................................................................................................................
............................................................................................................................................. [1]
(c) Each line of a text file contains several data items. A special character is inserted between
data items before the line is written to the file.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
(d) Each pseudocode statement in the following table may contain an error due to the incorrect
use of the function or operator.
Describe the error in each case, or write ‘NO ERROR’ if the statement contains no error.
Refer to the Appendix on page 18 for the list of built-in pseudocode functions and operators.
Statement Error
Status MID("Computer", 7, 5)
Size LENGTH("Password") * 2
NextChar CHR('A')
PROCEDURE LEM()
Overload FALSE
Landed FALSE
ENDPROCEDURE
Answer
[5]
[5]
© UCLES 2021 9608/22/M/J/21 [Turn over
6
3 (a) (i) Module names and parameters are features that may be represented on a structure
chart.
Feature 1 ...........................................................................................................................
Feature 2 ...........................................................................................................................
[2]
(ii) The headers for three modules in a program are defined in pseudocode as follows:
A fourth module, Membership(), may call any one of the three modules.
Draw a structure chart to represent the information given about the four modules.
[5]
(b) Draw a diagram to show the stages of the program development cycle. Use arrows to indicate
how the stages are linked.
[2]
4 (a) Using pseudocode, write a post-condition loop to output every odd number between 100
and 200.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
(b) A program contains a global 2D array XRef. The array consists of 100 rows and 3 columns.
The array is of data type STRING.
A function, Search(), takes two parameters Par1 and Par2 as string values and returns an
integer value.
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
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
© UCLES 2021 9608/22/M/J/21 [Turn over
10
Feature 1 ...........................................................................................................................
...........................................................................................................................................
Feature 2 ...........................................................................................................................
...........................................................................................................................................
[2]
(ii) Name two IDE features that can help with initial error detection.
Feature 1 ...........................................................................................................................
...........................................................................................................................................
Feature 2 ...........................................................................................................................
...........................................................................................................................................
[2]
..............................................
DECLARE Password : STRING
OUTPUT "Please Input your password: "
INPUT Password
Response Validate(UserID, Password) AND Today()
..............................................
ENDFUNCTION
[2]
• if the UserID is "Guest", a password is not required and TRUE should be returned
• output a message to try again if the password entered is not valid
• return FALSE if the number of attempts to enter a valid password exceeds three.
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 2021 9608/22/M/J/21 [Turn over
12
6 A program stores data about stock items in four global 1D arrays as follows:
The program will be modified so that the data from the arrays can be stored in a text file for
backup. You may assume that a backup file contains only valid stock data.
Module Description
• called with two parameters:
• an array index
Unpack()
• a string value read from one line of the backup file
• extracts the four data values from the string and assigns each
to the appropriate array
• called with a string representing the name of a backup file
• returns FALSE if the file is empty
• sets all elements of each array to the initial data value as given
in the table
Restore() • reads the backup file line by line
calls Unpack() to extract data from each line and assign
values to the corresponding arrays
• returns FALSE if the arrays are full but there are still lines in the
file, otherwise returns TRUE
For all items where StockID does not contain the initial value:
• counts the number of stock entries in the StockID array
StockSummary() • outputs the overall value of all items in stock (cost multiplied by
the quantity)
• outputs the number of stock entries
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
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
Module Description
• prompts and inputs a filename
• validates the filename by checking that it:
• is between 4 and 10 characters in length (inclusive)
GetValidFilename() • contains only alphanumeric characters
• if the filename is invalid, outputs a warning message and
asks the user to try again
• otherwise returns the valid filename
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
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
Appendix
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.
Published
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge International will not enter into discussions about these mark schemes.
Cambridge International is publishing the mark schemes for the May/June 2021 series for most Cambridge
IGCSE™, Cambridge International A and AS Level components and some Cambridge O Level components.
These general marking principles must be applied by all examiners when marking candidate answers.
They should be applied alongside the specific content of the mark scheme or generic level descriptors
for a question. Each question paper and mark scheme will also comply with these marking principles.
• the specific content of the mark scheme or the generic level descriptors for the question
• the specific skills defined in the mark scheme or in the generic level descriptors for the question
• the standard of response required by a candidate as exemplified by the standardisation scripts.
Marks awarded are always whole marks (not half marks, or other fractions).
• marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit
is given for valid answers which go beyond the scope of the syllabus and mark scheme,
referring to your Team Leader as appropriate
• marks are awarded when candidates clearly demonstrate what they know and can do
• marks are not deducted for errors
• marks are not deducted for omissions
• answers should only be judged on the quality of spelling, punctuation and grammar when these
features are specifically assessed by the question as indicated by the mark scheme. The
meaning, however, should be unambiguous.
Rules must be applied consistently, e.g. in situations where candidates have not followed
instructions or in the application of generic level descriptors.
Marks should be awarded using the full range of marks defined in the mark scheme for the question
(however; the use of the full mark range may be limited according to the quality of the candidate
responses seen).
Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should
not be awarded with grade thresholds or grade descriptors in mind.
Mechanics of Marking:
Every mark given should have a corresponding tick on the script.
Every part question must be annotated to show that it has been read.
There are four pages that appear at the start of the script (including the Appendix page) that
must be annotated with the SEEN icon. The easiest way to do this is to go the first question
and select Zoom > ‘fit height’ then all six can be annotated at the same time without scrolling.
Do not put comments on the scripts. When scripts are returned to centres all the annotations
including comments, are visible.
If work has been crossed out and something written in its place, the replacement work is marked even
if the crossed-out work is correct. If the crossed-out work has not been replaced, mark the crossed-
out answer.
For single mark answers, mark the first answer on the line, unless there is a note to the contrary on
the mark scheme.
If a candidate writes something that is not enough (NE) for a mark, but is not actually incorrect,
continue reading, even if the mark scheme says, for example, mark first two answers.
The use of NR (No Response) is described in this extract from the RM Assessor guide:
For questions requiring program code, if the only thing that is written is the name of the program
language then award NE.
In each case, if the second page of the response (page 15 and page 17 respectively) is blank then
add the annotation ‘SEEN’ to the second page.
1(a) One mark for each type and one mark for corresponding reason (not 4
dependant)
Type: Corrective
Reason: Because the program does not function as intended / contains a
bug
Type: Adaptive
Reason: Change the program due to a requirement / specification /
legislative change
Type: Perfective
Reason: Improve the performance of the program / to enhance the program
Type: Preventive
Reason: Improve maintainability or reliability
1(d) 5
Statement Error
Status ← MID("Computer",
Not enough characters
7, 5)
Size ← LENGTH("Password")
NO ERROR
* 2
2(a) 5
Answer
Sample() //
The name of a function
SubA() // SubB()
2(b) 5
Module...
• Hierarchy / relationships
• Selection
• Repetition / Iteration
• Sequence
3(a)(ii) 5
3(b) 2
Design
Coding
Testing
REPEAT
OUTPUT Num
Num ← Num + 2
UNTIL Num > 199
Mark as follows:
1 Counter declaration and initialisation to sensible value before the loop
2 REPEAT ... UNTIL <condition>
3 Correct selection of number to be output (use of MOD() or +2 or other)
4 Correct range of numbers output
Index ← 1
RetVal ← -1
RETURN RetVal
ENDFUNCTION
Mark as follows:
1 Function heading and ending including parameters
2 Declaration of local variable for array index (Index) but not of global
XRef array
3 Any loop for 100 elements
4 Use of correct XRef 2D array syntax in a loop
5 Logical test of array elements in a loop
6 Exit loop if match found (following attempt at MP5)
Return index number or −1 if not found
Max 2 marks
Max 2 marks
Count ← 1
Response ← FALSE
RETURN Response
ENDFUNCTION
PROCEDURE StockSummary()
DECLARE Index, Count : INTEGER
DECLARE Total : REAL
Count ← 0
Total ← 0.0
ENDPROCEDURE
Success ← TRUE
OPENFILE Filename FOR READ
READFILE Filename, FileLine
IF FileLine = "" THEN //alt: IF EOF(filename)
CLOSEFILE Filename
RETURN FALSE //file is empty
ENDIF
RETURN Success
ENDFUNCTION
REPEAT
Valid ← TRUE
OUTPUT "Please input the name for the backup file "
INPUT Filename
IF LENGTH(Filename) < 4 OR LENGTH(Filename) > 10
THEN
Valid ← FALSE
ELSE
Index ← 1
WHILE Index <= LENGTH(Filename) AND Valid = TRUE
NextChar ← MID(Filename, Index, 1)
IF NOT ((NextChar >='a' AND NextChar <='z')
OR (NextChar >='A' AND NextChar <='Z')
OR (NextChar >='0' AND NextChar <='9'))
THEN
Valid ← FALSE //not alphanumeric
ENDIF
Index ← Index + 1
ENDWHILE
ENDIF
Index = 1
RetVal = -1
Return RetVal
End Function
var
Index : integer;
RetVal : integer;
begin
Index := 1;
RetVal := -1;
Index := Index + 1;
end;
Index = 1
RetVal = -1
return RetVal
Count = 1
Response = FALSE
Return Response
End Function
begin
Count := 1;
end;
def Verify(UserID):
## Count As INTEGER
## Response As BOOLEAN
## Password As STRING
Count = 1
if UserID == "Guest":
return TRUE
return Response
Sub StockSummary()
Dim Index, Count As Integer
Dim Total As Real
Count = 0
Total = 0.0
End Sub
procedure StockSummary();
var
Index, Count : Integer;
Total : Real;
begin
Count := 0;
Total := 0.0;
end;
def StockSummary():
Count = 0
Total = 0.0
Valid = FALSE
Do
Valid = TRUE
Console.writeline("Please input the name for the backup file ")
Filename = Console.readline()
If Len(Filename) < 4 Or Len(Filename) > 10 Then
Valid = FALSE
Else
Index = 1
While Index <= Len(Filename) And Valid = TRUE
NextChar = MID(Filename, Index, 1)
If Not ((NextChar >='a' AND NextChar <='z') _
Or (NextChar >='A' AND NextChar <='Z')_
Or (NextChar >='0' AND NextChar <='9')) Then
Valid = FALSE //not alphanumeric
End If
Index = Index + 1
End While
End If
begin
Valid := FALSE;
repeat
Valid := TRUE;
writeln('Please input the name for the backup file ');
readln(Filename);
if length(Filename) < 4 Or length(Filename) > 10 then
Valid := FALSE
else
begin
Index := 1;
while Index <= length(Filename) And Valid = TRUE do
begin
NextChar := MidStr(Filename, Index, 1);
if Not ((NextChar >='a' AND NextChar <='z')
Or (NextChar >='A' AND NextChar <='Z'
Or (NextChar >='0' AND NextChar <='9')) then
Valid := FALSE; //not alphanumeric
Index := Index + 1;
end;
end;
def GetValidFilename():
## Filename As String
## Valid As Boolean
## Index As Integer
## NextChar As Char
Valid = FALSE
Valid = FALSE
Index = Index + 1
if Valid == FALSE:
print("Invalid filename – please try again")
return Filename