Computer Science (9608) · May/June 2017 · Mark scheme 22
Cambridge Computer Science (9608) mark scheme for paper 22, May/June 2017 — 9608/22/M/J/17, file 9608_s17_ms_22.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge International Examinations
Cambridge International Advanced Subsidiary and Advanced Level
COMPUTER SCIENCE
9608/22
Paper 2 Written Paper
May/June 2017
MARK SCHEME
Maximum Mark: 75
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 will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the May/June 2017 series for most Cambridge IGCSE®,
Cambridge International A and AS Level and Cambridge Pre-U components, and some Cambridge O Level
components.
® IGCSE is a registered trademark.
This document consists of 8 printed pages.
© UCLES 2017
[Turn over
May/June 2017
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
PUBLISHED
9608/22
Question
Answer
1(a)
Item
Marks
Statement
Input
Process
Output
1
SomeChars = "Hello World"
9
2
OUTPUT RIGHT(String1,5)
9
9
3
READFILE (MyFile, String2)
4
WRITEFILE (MyFile, "Data is " & String2)
9
9
6
9
Mark as follows:
Row 1 as shown
Row 2 no marks if tick in Input column, otherwise 1 mark per tick
Row 3 as shown
Row 4 no marks if tick in Input column, otherwise 1 mark per tick
1(b)(i)
•
•
Integer / Real / Single / Double / Floating Point / Float
Boolean
1(b)(ii)
Expression
Evaluates to
(FlagA AND FlagB) OR FlagC
TRUE
FlagA AND (FlagB OR FlagC)
TRUE
(NOT FlagA) OR (NOT FlagC)
FALSE
2
3
1 mark per answer
1(c)
MyCount ← 101
4
REPEAT
OUTPUT MyCount
MyCount ← MyCount + 2
UNTIL MyCount > 199
1 mark for each of the following:
•
•
•
•
Counter initialisation
Repeat « Until loop
Method for choosing (correct range of) odd numbers
Output all odd numbers in the range
Note: Counter variable name must be consistent
© UCLES 2017
Page 2 of 8
May/June 2017
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
PUBLISHED
9608/22
Question
2(a)
Answer
•
to increase the level of detail of an algorithm / design...
Marks
2
// breaking down a problem / module / task into smaller parts«
•
«from which the task may be programmed
1 mark per underlined phrase or equivalent
2(b)
1 mark for first 3 data types – String
1 mark for last data type – Boolean
5
1 mark for each description:
FileUserID
Stores (User) ID from file
FilePreferredName Stores (preferred) name from file
IDFoundFlag
True if (User) ID found in file // False if (User) ID not found in
file
// If SearchUserID matches FileUserID
2(c)
1.
2.
3.
4.
5.
6.
7.
8.
LOOP through the file until EOF()«
OR SearchUserId is found
READ text line from UserNames.txt file in a loop
EXTRACT FileUserID in a loop
IF SearchUserId matches FileUserID THEN in a loop
SET FilePreferredName to the name from the file
Check if User ID found not in a loop
OUTPUT appropriate message for both conditions
1 mark per functional equivalent of each numbered statement.
© UCLES 2017
Page 3 of 8
Max 8
May/June 2017
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
PUBLISHED
9608/22
Question
3
Answer
Marks
FUNCTION ExCamel (InString: STRING) RETURNS STRING
DECLARE NextChar : CHAR
DECLARE OutString : STRING
DECLARE n : INTEGER
OutString ← ""
// initialise the return string
// loop through InString to produce OutString
FOR n ← 1 TO LENGTH(InString)
// from first to last
NextChar ← MID(InString, n, 1) // get next character
IF NextChar >= 'A' AND NextChar <= 'Z' // check if upper
case
// NextChar = UCASE(NextChar)
THEN
IF n > 1
// if not first character
THEN
OutString ← OutString & " "
// add space
to OutString
ENDIF
NextChar ← LCASE(NextChar) // make NextChar lower
case
ENDIF
OutString ← OutString & NextChar
ENDFOR
RETURN OutString
ENDFUNCTION
// return value
1 mark per underlined word / expression
© UCLES 2017
// add Nextchar to
OutString
Page 4 of 8
Max 11
May/June 2017
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
PUBLISHED
9608/22
Question
4(a)
Answer
•
•
•
Marks
Max 2
Functions
Procedures
Global / Local variables
1 mark per item
4(b)
Name of parameter
passing method
Value
output
Explanation
(Call) by reference
5
•
•
The address of the variable is passed.
Original value is changed when parameter
changed in called module.
(Call) by value
4
•
•
A copy of the variable itself is passed.
Original value not changed when
parameter changed in called module.
6
Mark as follows:
• 1 mark for each name and value
• 1 mark per bullet in explanation
Question
Answer
5(a)(i)
•
•
5(a)(ii)
DECLARE LogArray : ARRAY[1 : 20] OF STRING
Any character except colon, space or any alpha-numeric
Reason: character is not in the login information strings
1 mark per underline
© UCLES 2017
Page 5 of 8
Marks
2
2
May/June 2017
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
PUBLISHED
9608/22
Question
Answer
5(b)
Pseudocode solution included here for development and clarification of mark scheme.
Programming language example solutions appear in the Appendix.
PROCEDURE LogEvents()
DECLARE FileData : STRING
DECLARE ArrayIndex : INTEGER
OPENFILE "LoginFile.txt" FOR APPEND
FOR ArrayIndex ← 1 TO 20 //
IF LogArray[ArrayIndex]<> "****"
THEN
FileData ← LogArray[ArrayIndex]
WRITEFILE ("LoginFile.txt", FileData)
ENDIF
ENDFOR
CLOSEFILE("LoginFile.txt")
ENDPROCEDURE
1 mark for each of the following:
1.
2.
3.
4.
5.
6.
7.
8.
© UCLES 2017
Procedure heading and ending
Declare ArrayIndex as integer // commented in python
Open file 'LoginFile' for append
Correct loop
extract data from array in a loop
check for unused element in a loop
write data to file in a loop
Close the file outside the loop
Page 6 of 8
Marks
8
May/June 2017
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
PUBLISHED
9608/22
Question
Answer
Marks
6(a)
Pseudocode solution included here for development and clarification of mark scheme.
Programming language example solutions appear in the Appendix.
Max 9
FUNCTION ValidateRegistration(Registration : STRING) RETURNS
BOOLEAN
DECLARE UCaseChar, NumChar : INTEGER
DECLARE NextChar : CHAR
DECLARE ReturnFlag : BOOLEAN
DECLARE n : INTEGER
ReturnFlag ← TRUE
ValidateRegistration ← True
IF LEN(Registration) < 6 OR LEN(Registration) > 9
//check
length
THEN
ReturnFlag ← False
ELSE
FOR n ← 1 TO 3
//check for 3 upper case alpha
NextChar ← MID(Registration, n, 1)
IF NextChar < 'A' AND NextChar > 'Z'
THEN
ReturnFlag ← False
ENDIF
ENDFOR
FOR n ← 4 TO 5
//check for 2 numeric
NextChar ← MID(Registration, n, 1)
IF NextChar < '0' AND NextChar > '9
THEN
ReturnFlag ← False
ENDIF
ENDFOR
FOR n ← 6 TO LEN(Registration) //check remaining
characters
NextChar ← MID(Registration, n, 1)
IF NextChar < 'A' AND NextChar > 'Z'
THEN
ReturnFlag ← False
ENDIF
ENDFOR
ENDIF
RETURN (ReturnFlag)
ENDFUNCTION
© UCLES 2017
Page 7 of 8
May/June 2017
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
PUBLISHED
9608/22
Question
6(a)
Answer
1 mark for each of the following:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
6(b)
Marks
Correct Function heading and ending
Check for correct length
Extract first three characters
Check first three characters are capitals
Extract characters four and five
Check characters four and five are numeric
Extract remaining characters
Check remaining characters are capitals
Combine all four tests results into a single Boolean value
Return a Boolean value
String1: (for example, "ABC12XYZ")
5
One mark for a valid string having:
• Correct length (between 6 and 9 characters)
• 3 capital letters followed by«
• 2 numeric characters followed by«
• between 1 and 4 capital letters
String2 to String5:
1 mark for each string and explanation (testing different rules of the function)
Test strings breaking one different rules:
• Incorrect length
• With incorrect number of capital letters at the start
• With non-numeric characters in positions 4 and 5
• With incorrect number of capital letters at the end
• Containing an invalid character (not alpha-numeric)
© UCLES 2017
Page 8 of 8