Cambridge A Level Computer Science 9608 — 2018 May/June Paper 2 · Variant 3

9608/23/M/J/18 · 75 marks · ≈84 min

The question paper and its mark scheme, free to read here and free to download. This is Cambridge’s own paper, exactly as it was sat.

← All Computer Science papersWhat was in this paper?

Question paper16 pages

Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 1 of 16
Page 1 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 2 of 16
Page 2 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 3 of 16
Page 3 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 4 of 16
Page 4 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 5 of 16
Page 5 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 6 of 16
Page 6 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 7 of 16
Page 7 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 8 of 16
Page 8 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 9 of 16
Page 9 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 10 of 16
Page 10 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 11 of 16
Page 11 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 12 of 16
Page 12 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 13 of 16
Page 13 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 14 of 16
Page 14 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 15 of 16
Page 15 of 16
Cambridge A Level Computer Science 9608 2018 May/June Paper 2 · Variant 3 question paper, page 16 of 16
Page 16 of 16

Mark scheme13 pages

Answers below. Sit the paper first if you are practising.

Mark scheme, page 1 of 13
Page 1 of 13
Mark scheme, page 2 of 13
Page 2 of 13
Mark scheme, page 3 of 13
Page 3 of 13
Mark scheme, page 4 of 13
Page 4 of 13
Mark scheme, page 5 of 13
Page 5 of 13
Mark scheme, page 6 of 13
Page 6 of 13
Mark scheme, page 7 of 13
Page 7 of 13
Mark scheme, page 8 of 13
Page 8 of 13
Mark scheme, page 9 of 13
Page 9 of 13
Mark scheme, page 10 of 13
Page 10 of 13
Mark scheme, page 11 of 13
Page 11 of 13
Mark scheme, page 12 of 13
Page 12 of 13
Mark scheme, page 13 of 13
Page 13 of 13

Paper as text

Question paper, page 1

* 8 9 5 5 0 1 7 8 4 7 * This document consists of 15 printed pages and 1 blank page. DC (CE/SG) 146142/3 © UCLES 2018 [Turn over Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/23 Paper 2 Fundamental Problem-solving and Programming Skills May/June 2018 2 hours Candidates answer on the Question Paper. No Additional Materials are required. No calculators allowed. READ THESE INSTRUCTIONS FIRST Write your Centre number, candidate number and name in the spaces at the top of this page. Write in dark blue or black pen. You may use an HB pencil for any diagrams, graphs or rough working. Do not use staples, paper clips, glue or correction fluid. DO NOT WRITE IN ANY BARCODES. Answer all questions. No marks will be awarded for using brand names of software packages or hardware. At the end of the examination, fasten all your work securely together. The number of marks is given in brackets [ ] at the end of each question or part question. The maximum number of marks is 75.

Question paper, page 2

2 9608/23/M/J/18 © UCLES 2018 1 (a) A program controls the heating system of an energy-efficient house. Give a suitable identifier name for each of the data items. Description of data item Suitable identifier name The temperature inside the house The temperature outside the house The wind speed Whether it was raining or not [4] (b) (i) Program variables have values as follows: Variable Value Quality 'D' DayNumber 20 MyName "Stephen" QualityConfirmed TRUE Factor 6.5 Evaluate each expression in the following table. If an expression is invalid, write ERROR. For the built-in functions list, refer to the Appendix on page 15. Expression Evaluates to MID(MyName, 4, 4) & "ol" QualityConfirmed AND (Factor >= 6.5) 20 + ASC(Quality) QualityConfirmed + 3 MOD(Factor * 2, 9) [5]

Question paper, page 3

3 9608/23/M/J/18 © UCLES 2018 [Turn over (ii) Programming languages support different data types. Give an appropriate data type for each of these variables from part (b)(i). Variable Data type QualityConfirmed DayNumber Factor Quality MyName [5]

Question paper, page 4

4 9608/23/M/J/18 © UCLES 2018 2 The following is a function design in pseudocode. Line numbers are given for reference only. 01 FUNCTION GradeCalc(Mark : ARRAY[] OF INTEGER) RETURNS INTEGER 02 03 DECLARE DGradeCount : INTEGER 04 DECLARE n : INTEGER 05 DECLARE Grade : STRING 06 DECLARE ThisMark : INTEGER 07 08 DGradeCount 0 // initialise variables 09 n 1 10 ThisMark 1 11 REPEAT 12 ThisMark Mark[n] // get next mark from Mark array 13 14 IF ThisMark > 74 15 THEN 16 Grade "Distinction" 17 DGradeCount DGradeCount + 1 // one more Distinction 18 ELSE 19 IF ThisMark > 59 20 THEN 21 Grade "Merit" 22 ELSE 23 IF ThisMark > 39 24 THEN 25 Grade "Pass" 26 ELSE 27 Grade "Fail" 28 ENDIF 29 ENDIF 30 ENDIF 31 32 OUTPUT "Grade for Student " & n & " is " & Grade 33 34 n n + 1 35 UNTIL n = 101 // no more elements in the array 36 37 RETURN Grade // return the number of Distinction grades 38 39 ENDFUNCTION 40 41 DECLARE Mark : ARRAY[1:100] OF INTEGER 42 DECLARE DistinctionGrades : INTEGER 43 44 CALL GetMarks(Mark[]) // fill the array with student marks 45 DistinctionGrades GradeCalc(Mark[])

Question paper, page 5

5 9608/23/M/J/18 © UCLES 2018 [Turn over (a) This pseudocode includes features that are examples of good practice. Explain why it is useful to include the two following features. Comments … … Indentation … … [2] (b) Study the function GradeCalc(). Identify the features of the function in the following table. Feature Answer A line number containing an example of an integer assignment statement A line number containing the start of a selection structure A line number containing the end of a selection structure The upper bound of the Mark array The number of dimensions of the Mark array The name for the type of loop structure used A line number containing an unnecessary assignment statement The number of times OUTPUT is called The number of local variables [9] (c) (i) There is a mistake in the pseudocode that would produce a data type mismatch error if a programmer were to write similar program code. Describe this mistake and how it may be corrected. … … … …[2]

Question paper, page 6

6 9608/23/M/J/18 © UCLES 2018 (ii) Lines 14 to 30 of the pseudocode on page 4 could be written using a CASE structure. Write the equivalent CASE structure in pseudocode. … … … … … … … … … …[4]

Question paper, page 7

7 9608/23/M/J/18 © UCLES 2018 [Turn over 3 A modular program design consists of four modules: Module1 has three sub-tasks. Each sub-task is implemented by a single subroutine (either a function or a procedure). The subroutine headings are defined as follows: FUNCTION Module2 (Weight : REAL) RETURNS BOOLEAN PROCEDURE Module3 (Weight : REAL, Customer : STRING, Purchased : DATE) FUNCTION Module4 (Purchased : DATE, Account : INTEGER) RETURNS INTEGER (a) State the term given to values passed between modules. …[1] (b) Draw a structure chart to represent the program design. Use the letters in the table to label the values passed between modules. Value Label Boolean return value A Integer return value B Account C Customer D Purchased E Weight F Structure chart [4]

Question paper, page 8

8 9608/23/M/J/18 © UCLES 2018 4 A program controls a chemical process in a factory. The temperature is monitored as part of the control process. The temperature is measured at fixed time intervals and the value is stored in an array, PTemp. The array contains 100 elements, representing 100 temperature values. The first element is PTemp[1]. The program will check whether the temperature is outside the acceptable range more than 20 times. This task is performed by a function, IsTempOK(). The algorithm for the function IsTempOK() is expressed in structured English as follows: 1 Examine each array element and count the number of times that a temperature is less than MinTemp or more than MaxTemp. 2 If the count in step 1 exceeds 20, return FALSE, otherwise return TRUE. Draw a program flowchart, on the next page, to represent the algorithm for the function IsTempOK(). Assume: • the array contains 100 valid temperature values • PTemp, MinTemp and MaxTemp are global variables. Note that variable declarations are not required in program flowcharts.

Question paper, page 9

9 9608/23/M/J/18 © UCLES 2018 [Turn over [9]

Question paper, page 10

10 9608/23/M/J/18 © UCLES 2018 5 A golf club holds information about its members. When a member completes a round of golf, their score is stored along with their membership number and the date of the round. A program is to be written to store and process the score information. The information to be stored is as follows: • MembershipNumber is a four-digit numeric string. • Date is a six-digit numeric string in the format DDMMYY • Score is a two-digit numeric string in the range “50” to “99”. This information is stored in a single string in the format: <MembershipNumber><Date><Score> (a) (i) The program designer considers storing the strings in an array. State how many dimensions the array would require. …[1] (ii) The designer has decided to store the strings in a file. Give a reason for this choice. … …[1] (b) The program will be developed using an Integrated Development Environment (IDE). One feature provided by an IDE is known as prettyprint. Name two presentation features provided by prettyprint. Feature 1 … … Feature 2 … … [2] (c) The strings are stored in a text file, ScoreDetails.txt. The program needs a function, GetAverageScore(). The structured English representing the algorithm for this function is as follows: 1 Receive a membership number as its argument. 2 Search the ScoreDetails.txt file for all scores for that member. 3 Calculate the average score. 4 Return the average score. You can assume that there will be at least one score relating to each member.

Question paper, page 11

11 9608/23/M/J/18 © UCLES 2018 [Turn over Write program code for the GetAverageScore() function. Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type. Programming language … Program Code … … … … … … … … … … … … … … … … … … … … … … … …[10]

Question paper, page 12

12 9608/23/M/J/18 © UCLES 2018 6 (a) Individual elements in a 1D array are referenced using an integer variable. For example, using the variable n, an individual element would be referenced in pseudocode as: StudentGrade[n] Give the correct technical term for the variable n. …[1] (b) A 2D array, Picture, contains data representing a bitmap image. Each element of the array represents one pixel of the image. The image is grey-scale encoded where the value of each pixel ranges from 0 (representing black) to 255 (representing white) with intermediate values representing different levels of grey. The following is an example of an image and the corresponding data values for the Picture array. 240 240 80 80 80 80 80 240 240 240 80 80 80 80 80 10 150 150 150 150 150 150 150 150 150 240 150 240 240 10 150 240 150 80 80 10 150 240 150 80 80 10 150 240 150 240 240 10 240 240 80 80 80 80 80 10 240 240 80 80 80 80 80 240 Values Bitmap image In pseudocode, the array is declared as follows: DECLARE Picture : ARRAY[1:8, 1:8] OF INTEGER A function, Clip(), is required that will: • take an integer parameter, MaxVal, to represent the maximum allowed value for each pixel • limit each pixel value to the maximum allowed value • return TRUE if any of the pixel values have been changed, otherwise return FALSE An example use of the function is: IsClipped Clip(234) This will limit the maximum pixel value within the array to 234. Pixels with a value not greater than 234 will remain unchanged.

Question paper, page 13

13 9608/23/M/J/18 © UCLES 2018 [Turn over Write pseudocode to implement the Clip() function. Assume that Picture is a global variable. … … … … … … … … … … … … … … … … … … … … … … …[9]

Question paper, page 14

14 9608/23/M/J/18 © UCLES 2018 7 A function, IsFactor() takes two integer parameters and checks whether the second parameter is a factor of the first parameter. For example IsFactor(6,3) would return TRUE as six divided by three has a remainder of zero. This function returns FALSE if there is a non-zero remainder, or if the value of the second parameter is zero. Write program code to implement the IsFactor() function. Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type. Programming language … Program code … … … … … … … … … … … … … … … …[6]

Question paper, page 15

15 9608/23/M/J/18 © UCLES 2018 Appendix Built-in functions (pseudocode) Each function returns an error if the function call is not properly formed. MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING returns a string of length y starting at position x from ThisString Example: MID("ABCDEFGH", 2, 3) returns string "BCD" LENGTH(ThisString : STRING) RETURNS INTEGER returns the integer value representing the length of string ThisString Example: LENGTH("Happy Days") returns 10 LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING returns leftmost x characters from ThisString Example: LEFT("ABCDEFGH", 3) returns string "ABC" RIGHT(ThisString : STRING, x : INTEGER) RETURNS STRING returns rightmost x characters from ThisString Example: RIGHT("ABCDEFGH", 3) returns string "FGH" INT(x : REAL) RETURNS INTEGER returns the integer part of x Example: INT(27.5415) returns 27 ASC(ThisChar : CHAR) RETURNS INTEGER returns the ASCII value of character ThisChar Example: ASC(′A') returns 65 MOD(ThisNum : INTEGER, ThisDiv : INTEGER) RETURNS INTEGER returns the integer value representing the remainder when ThisNum is divided by ThisDiv Example: MOD(10,3) returns 1 Operators (pseudocode) Operator Description & Concatenates (joins) two strings. Example: "Summer" & " " & "Pudding" produces "Summer Pudding" AND Performs a logical AND of two Boolean values. Example: TRUE AND FALSE produces FALSE OR Performs a logical OR of two Boolean values. Example: TRUE OR FALSE produces TRUE

Question paper, page 16

16 9608/23/M/J/18 © UCLES 2018 Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity. To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series. Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge. BLANK PAGE

Mark scheme, page 1

IGCSE™ is a registered trademark. This document consists of 13 printed pages. © UCLES 2018 [Turn over Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/23 Paper 2 Written Paper May/June 2018 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 International will not enter into discussions about these mark schemes. Cambridge International is publishing the mark schemes for the May/June 2018 series for most Cambridge IGCSE™, Cambridge International A and AS Level and Cambridge Pre-U components, and some Cambridge O Level components.

Mark scheme, page 2

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 2 of 13 Generic Marking Principles 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. GENERIC MARKING PRINCIPLE 1: Marks must be awarded in line with: • 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. GENERIC MARKING PRINCIPLE 2: Marks awarded are always whole marks (not half marks, or other fractions). GENERIC MARKING PRINCIPLE 3: Marks must be awarded positively: • 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. GENERIC MARKING PRINCIPLE 4: Rules must be applied consistently e.g. in situations where candidates have not followed instructions or in the application of generic level descriptors. GENERIC MARKING PRINCIPLE 5: 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). GENERIC MARKING PRINCIPLE 6: 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.

Mark scheme, page 3

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 3 of 13 Question Answer Marks 1(a) Description of data item Suitable identifier name The temperature inside the house InsideTemperature The temperature outside the house OutsideTemperature The wind speed WindSpeed Whether it was raining or not WasRaining The above are examples only. Names must be meaningful and unambiguous Items 1 and 2 must have suitable prefix/suffix (i.e. not just ‘temperature’) Reject single letter names 4 1(b)(i) Expression Evaluates to MID(MyName, 4, 4) & "ol" "phenol" QualityConfirmed AND (Factor >= 6.5) TRUE 20 + ASC(Quality) 88 QualityConfirmed + 3 ERROR MOD(Factor * 2, 9) 4 5 1(b)(ii) Variable Data type QualityConfirmed BOOLEAN DayNumber INTEGER Factor REAL Quality CHAR MyName STRING One mark per answer 5

Mark scheme, page 4

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 4 of 13 Question Answer Marks 2(a) Comments: Explain the functionality of the code // Easier for other people to understand // Easier to maintain / debug / modify Indentation: Easier to identify structure / blocks // identify blocks of code 2 2(b) Feature Answer A line number containing an example of an integer assignment statement 8, 9, 10,12, 17, 34, 45 A line number containing the start of a selection structure 14, 19, 23 A line number containing the end of a selection structure 28, 29, 30 The upper bound of the Mark array 100 The number of dimensions of the Mark array 1 The name for the type of loop structure used ‘post condition’ A line number containing an unnecessary assignment statement 10 The number of times that OUTPUT is called 100 The number of local variables 4 9 2(c)(i) Either: • Mistake: function header specifies return of an INTEGER but line 37 returns a STRING // pseudocode returns Grade but should have returned DGradeCount • Correction: RETURN DGradeCount (as per code pseudocode comment) Or: • Mistake: Statement on line 32 uses ‘&’ operator which concatenates STRINGs, but variable n is an INTEGER • Correction: Convert n to a STRING before concatenating 2

Mark scheme, page 5

9 © 9608/23 © UCLES 2018 Question 2(c)(ii) Question 3(a) 3(b) CASE OF 60 40 OTH ENDCASE One mar 1 CASE 2 Thre 3 DGra 4 OTHE Paramete Accept a Mark as f • One • One Cambridg F ThisMar > 74: TO 74: TO 59: HERWISE E rk for each o E OF This ee grade ran adeCount ERWISE / fo ers rguments follows: mark for al mark for ea ge Internatio P rk Grade ← DGradeCo Grade ← Grade ← Grade ← of: sMark ... nges with co increment w ourth grade l four modu ach set of in onal AS/A L PUBLISHED Page 5 of 13 Answer "Distinc ount ← DG "Merit" "Pass" "Fail" . ENDCASE orrespondin within CASE range with Answer ules nterface pa Level – Mar D r ction" GradeCoun E ng assignm E clause correct ass r rameters k Scheme nt + 1 ent of Grad signment of Ma de f Grade ay/June 201 Marks 4 Marks 1 4 18 4 1 4

Mark scheme, page 6

9 © 9608/23 © UCLES 2018 Question 4 This is on One mar 1 STAR 2 Initia 3 Deci 4 Corr 5 Deci 6 Corr 7 Deci 8 Assig 9 Retu For solut 8 Retu 9 R Cambridg ne possible rk for: RT and END alisation of a ision box / b rect increme ision box co rect increme ision box co gning both urning the B tions where urn TRUE Return FALS ge Internatio P solution – s D // STOP an Index v boxes to che ent of Coun omparing In ent of Inde omparing Co TRUE and F Boolean valu Boolean va SE onal AS/A L PUBLISHED Page 6 of 13 Answer selection st P variable and eck temper t variable ndex to 100 x ount > 20 FALSE ue ariable not u Level – Mar D r tructure ma d initialisatio rature within used: k Scheme y differ on of a Coun n acceptable Ma nt variable e range ay/June 201 Marks e 9 18 9

Mark scheme, page 7

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 7 of 13 Question Answer Marks 5(a)(i) 1 1 5(a)(ii) Information is saved after the program ends // after the computer is switched off 1 5(b) Two from these examples: • Indentation • Colour-coding of keywords /comments • Expansion / collapsing of complex data structures Max 2

Mark scheme, page 8

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 8 of 13 Question Answer Marks 5(c) ‘Pseudocode’ solution included here for development and clarification of mark scheme. Programming language solutions appear in the Appendix. FUNCTION GetAverageScore(MembershipNumber : STRING) RETURNS INTEGER DECLARE FileData, FileMembershipNumber : STRING DECLARE NumberOfScores, TotalScore, AverageScore : INTEGER OPENFILE "ScoreDetails.txt" FOR READ NumberOfScores ← 0 TotalScore ← 0 WHILE NOT EOF("ScoreDetails.txt") READFILE("ScoreDetails.txt", FileData) FileMembershipNumber ← LEFT(FileData, 4) IF FileMembershipNumber = MembershipNumber THEN NumberOfScores ← NumberOfScores + 1 TotalScore ← TotalScore + INT(RIGHT(FileData, 2)) ENDIF ENDWHILE AverageScore ← INT(TotalScore / NumberOfScores) CLOSEFILE("ScoreDetails.txt") RETURN(AverageScore) ENDFUNCTION 1 mark for each of the following: 1 Function heading and ending including Input and return parameter 2 Declare variables to store NumberOfScores and TotalScore as INTEGERs (commented in Python) (variable names may be different) 3 Initialisation of NumberOfScores and TotalScore to 0 4 Open file in READ mode 5 Loop until EOF() 6 Read a line from the file in a loop 7 Use of substring function to extract at least one data item 8 Compare the membership number 9 Convert score to an integer 10 Increment NumberOfScores and sum TotalScore 11 Calculate the average outside the loop 12 Close the file 13 Return the parameter Max 10

Mark scheme, page 9

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 9 of 13 Question Answer Marks 6(a) Subscript / index 1 6(b) FUNCTION Clip(MaxVal : INTEGER) RETURNS BOOLEAN DECLARE i : INTEGER DECLARE j : INTEGER DECLARE ClipFlag : BOOLEAN ClipFlag ← FALSE FOR i ← 1 TO 8 FOR j ← 1 TO 8 IF Picture[i, j] > MaxVal THEN Picture[i, j] ← MaxVal ClipFlag ← TRUE ENDIF ENDFOR ENDFOR RETURN ClipFlag ENDFUNCTION 1 mark for each of the following: 1 Correct Function heading (must have MaxVal and return a BOOLEAN) and ending 2 Declare and initialise local variable for return BOOLEAN to FALSE / other mechanism to record pixel being clipped 3 Declare local variables for loop counters 4 Nested loops with correct number of iterations 5 Accessing correct element from Picture array 6 Comparing element with MaxVal 7 Changing value of element if necessary 8 Setting flag to TRUE / other mechanism if element is changed 9 Returning BOOLEAN after loop (following conversion if other mechanism used) 9

Mark scheme, page 10

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 10 of 13 Question Answer Marks 7 ‘Pseudocode’ solution included here for development and clarification of mark scheme. Programming language solutions appear in the Appendix. FUNCTION IsFactor(Num1: INTEGER, Num2: INTEGER) RETURNS BOOLEAN IF Num2 <> 0 THEN IF MOD(Num1, Num2) = 0 THEN RETURN TRUE ENDIF ENDIF RETURN FALSE ENDFUNCTION 1 mark for each of the following: 1 Correct Function heading (including parameters) and ending 2 Check that Num2 is not zero 3 Mechanism to ensure no call to MOD (or equivalent) if Num2 is zero 4 Use of MOD function or alternative 5 Check value of remainder 6 Return Boolean value 6 *** End of Mark Scheme – program code example solutions follow ***

Mark scheme, page 11

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 11 of 13 Appendix Program Code Example Solutions Q5(c): Visual Basic Function GetAverageScore(ByVal MembershipNumber As String) As Integer Dim FileData As String Dim FileMembershipNumber As String Dim NumberOfScores As Integer Dim TotalScore As Integer Dim AverageScore As Integer Dim ObjReader As IO.StreamReader ObjReader = New IO.StreamReader("ScoreDetails.txt") NumberOfScores = 0 TotalScore = 0 Do While ObjReader.Peek <> -1 FileData = ObjReader.ReadLine() FileMembershipNumber = LEFT(FileData, 4) If FileMembershipNumber = MembershipNumber Then NumberOfScores = NumberOfScores + 1 TotalScore = TotalScore + INT(RIGHT(FileData, 2)) End If Loop AverageScore = INT(TotalScore / NumberOfScores) ObjReader.Close() Return (AverageScore) End Function Q5(c): Pascal function GetAverageScore(MembershipNumber : string):integer; var FileData, FileMembershipNumber: string; NumberOfScores, TotalScore, AverageScore : integer; ScoreFile : textFile; begin NumberOfScores := 0; TotalScore := 0; assignFile(ScoreFile, ‘ScoreDetails.txt’); reset(ScoreFile); while not eof(ScoreFile) do begin readln(ScoreFile, FileData); FileMembershipNumber := copy(FileData, 1, 4); if FileMembershipNumber = MembershipNumber then begin NumberOfScores := NumberOfScores + 1 TotalScore := TotalScore + StrToInt(RightStr(FileData, 2)); end; end;

Mark scheme, page 12

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 12 of 13 AverageScore := StrToInt(TotalScore / NumberOfScores); GetAverageScore := AverageScore; CloseFile (ScoreFile); end; Q5(c): Python # FileData AS STRING # FileMembershipNumber AS STRING # NumberOfScores AS INTEGER # TotalScore AS INTEGER # AverageScore AS INTEGER def GetAverageScore(MembershipNumber): FileHandle = open("ScoreDetails.txt", "r") NumberOfScores = 0 TotalScore = 0 FileData = FileHandle.readline() while len(FileData) > 0: FileMembershipNumber = FileData[0:4] if FileMembershipNumber == MembershipNumber: NumberOfScores = NumberOfScores + 1 TotalScore = TotalScore + int(FileData[-2]) FileData = FileHandle.readline() AverageScore = int(TotalScore / NumberOfScores) Return (AverageScore) FileHandle.close()

Mark scheme, page 13

9608/23 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 13 of 13 Q7: Visual Basic Function IsFactor(Num1 As Integer, Num2 As Integer) As Boolean If Num2 <> 0 Then If Num1 Mod Num2 = 0 Then Return True End If End if Return False End Function Q7: Pascal function IsFactor(Num1,Num2 : integer) : boolean; begin if Num2 <> 0 then begin if Num1 MOD Num2 = 0 then Return True; end; Return False; end; Q7: Python def IsFactor (Num1, Num2): if Num2 != 0: if Num1 % Num2 == 0: Return True Return False

What you needed in this session

Cambridge’s own grade thresholds for 2018 May/June, Paper 2 · Variant 3. A higher threshold means an easier paper — the bar moves with how the cohort did.

A52/75
B44/75
C36/75
D28/75
E21/75