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

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

Mark scheme14 pages

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

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

Paper as text

Question paper, page 1

* 6 2 6 4 9 0 5 1 5 3 * This document consists of 15 printed pages and 1 blank page. DC (LK/CGW) 146140/3 © UCLES 2018 [Turn over Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/21 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/21/M/J/18 © UCLES 2018 Question 1 begins on the next page.

Question paper, page 3

3 9608/21/M/J/18 © UCLES 2018 [Turn over 1 (a) A program stores data about hospital patients. Give a suitable identifier name for each of the data items. Description of data item Suitable identifier name The temperature of the patient The temperature of the room The patient identification number The name of the nurse taking the measurement [4] (b) (i) Program variables have values as follows: Variable Value MyGreeting "Happy Birthday" MyInitial 'C' AgeInYears 27 Weight 60.5 Married TRUE Children TRUE 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 "Mon" & MID(MyGreeting, 10, 2) AgeInYears + ASC(MyInitial) INT(MyInitial) MOD(Weight * 2, 10) Married AND (NOT Children) [5] (ii) Programming languages support different data types. Give an appropriate data type for each of these variables from part (b)(i). Variable Data type MyGreeting MyInitial AgeInYears Weight Married [5]

Question paper, page 4

4 9608/21/M/J/18 © UCLES 2018 2 The following is a function design in pseudocode. Line numbers are given for reference only. 01 FUNCTION StringClean(InString : STRING) RETURNS STRING 02 03 DECLARE NextChar : CHAR 04 DECLARE OutString : STRING 05 DECLARE Counter : INTEGER 06 DECLARE MyString : STRING 07 08 OutString "" 09 10 FOR Counter 1 TO LENGTH(InString) 11 12 NextChar MID(InString,Counter,1) 13 NextChar LCASE(NextChar) 14 15 IF (NextChar >= 'a') AND (NextChar <= 'z') 16 17 THEN 18 19 OutString OutString & NextChar 20 21 ENDIF 22 23 ENDFOR 24 25 RETURN OutString 26 27 ENDFUNCTION (a) (i) This pseudocode includes features that make it easier to read and understand. State four such features. Feature 1 … Feature 2 … Feature 3 … Feature 4 … [4] (ii) State one feature that could be added to make the pseudocode easier to understand. …[1]

Question paper, page 5

5 9608/21/M/J/18 © UCLES 2018 [Turn over (b) Study the function StringClean(). Identify the features of the function in the following table. Feature Answer A line number containing an example of an assignment statement A line number containing the start of a repetition block A line number containing the end of a repetition block A line number containing the start of a selection statement The number of parameters of the MID function The Boolean operator used The number of local variables The number of function calls from within StringClean() resulting from the call: NewString StringClean("Me") The number of a line containing an unnecessary statement [9]

Question paper, page 6

6 9608/21/M/J/18 © UCLES 2018 3 In a chemical factory, a procedure, CheckSensor() is required to allow an operator to monitor the temperature in different locations. In the factory: • the temperature is measured by 10 sensors, each at a different location • each sensor has a unique ID (1 to 10). The procedure CheckSensor() will compare the measured temperature against each of two constant values, LowTemp and HighTemp. It will perform the following actions depending on the result of the comparison. Measured temperature Action below LowTemp Output "Cold" from LowTemp to HighTemp Output "Normal" above HighTemp Call procedure Alarm() A library function, GetTemp(), returns the temperature value from a given sensor. The structured English representing the algorithm for the procedure CheckSensor() is as follows: 1. Prompt for the input of a sensor ID. 2. Input a sensor ID. 3. If the sensor ID is invalid, repeat from step 1. 4. Call the GetTemp() function with the sensor ID as the parameter, to obtain the relevant temperature. 5. Compare the temperature against the two constant values and take the appropriate action. Draw a program flowchart on the next page to represent the algorithm for procedure CheckSensor(). Variable declarations are not required in program flowcharts.

Question paper, page 7

7 9608/21/M/J/18 © UCLES 2018 [Turn over [8]

Question paper, page 8

8 9608/21/M/J/18 © UCLES 2018 4 (a) A structure chart is used in modular program design. Iteration and selection are two features of an algorithm that may be shown on a structure chart. Give three other features. Feature 1 … … Feature 2 … … Feature 3 … … [3] (b) Pseudocode for a function is shown. FUNCTION ItemProcess (AddItem, InString : STRING) RETURNS BOOLEAN DECLARE RetFlag : BOOLEAN RetFlag FALSE IF AddItem = "Yes" THEN RetFlag AddToList(InString) ELSE CALL RemoveFromList(InString) ENDIF RETURN RetFlag ENDFUNCTION Draw a structure chart on the next page to represent this pseudocode.

Question paper, page 9

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

Question paper, page 10

10 9608/21/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) Explain why the club stores these data in a file rather than an array. … …[1] (b) Editing functions such as cut, copy and paste are features provided by an Integrated Development Environment (IDE). Give two additional features of an IDE that are helpful when coding a program. Feature 1 … … Feature 2 … … [2] (c) The information is stored in a text file, ScoreDetails.txt. The format of each line of the text file is as follows: <MembershipNumber><Date><Score> • 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". A procedure, AddNewScores(), is being developed. This will allow the user to enter scores for several members on a particular date. The procedure, AddNewScores(), will perform the following actions: 1. Prompt for the date of the scores. 2. Input the date of the scores. 3. Prompt for the membership number. 4. Input the membership number. 5. If the membership number is an empty string then end the procedure. 6. Prompt for the score. 7. Input the score. 8. Validate the score. 9. If the validation fails then repeat from step 6. 10. Form a text string from the data and write this to the ScoreDetails.txt file. 11. Repeat from step 3.

Question paper, page 11

11 9608/21/M/J/18 © UCLES 2018 [Turn over Write program code for the AddNewScores() procedure. 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 … … … … … … … … … … … … … … … … … … … … … … … …[9]

Question paper, page 12

12 9608/21/M/J/18 © UCLES 2018 6 (a) The following pseudocode includes references to a 1D array. DECLARE StudentGrade : ARRAY[1:5] OF CHAR DECLARE n : INTEGER DECLARE x : CHAR n 3 x StudentGrade[n] (i) Use the correct technical terms to explain the meaning of [1:5] in this pseudocode. … … … …[2] (ii) Use the correct technical term to complete the following statement. Integer n is used as the … to StudentGrade. [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

Question paper, page 13

13 9608/21/M/J/18 © UCLES 2018 [Turn over A function, Lighten(), is required to lighten the image. Lightening an image may cause it to ‘burn out’. An image is said to be ‘burnt out’ if any pixel is set to the maximum value of 255. The function Lighten() will: 1. increase the value of each pixel by 10% 2. return TRUE if the resultant image is ‘burnt out’. Write pseudocode to implement the Lighten() function. Assume that the array Picture is a global variable. … … … … … … … … … … … … … … … … … … … … … … …[8]

Question paper, page 14

14 9608/21/M/J/18 © UCLES 2018 7 A function, ProcessMarks(), is required to analyse test marks for a class of students. • There are 20 students in the class. • A mark is between 0 and 100. • The marks for the class are stored in an array, Mark, which has 20 elements. • The array is passed to the function as a parameter. • The function will output a message stating the average and highest marks. For example: "The average mark is 34 and the highest mark is 76" • The function returns the subscript of the highest mark. Write program code to implement the ProcessMarks() 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 … … … … … … … … … … … … … … … … … … …[7]

Question paper, page 15

15 9608/21/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" LCASE(ThisChar : CHAR) RETURNS CHAR returns the character value representing the lower case equivalent of ThisChar If ThisChar is not an upper-case alphabetic character then it is returned unchanged. Example: LCASE('W') returns 'w' 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 on two Boolean values Example: TRUE AND FALSE produces FALSE OR Performs a logical OR on two Boolean values Example: TRUE OR FALSE produces TRUE

Question paper, page 16

16 9608/21/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 14 printed pages. © UCLES 2018 [Turn over Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/21 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/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 2 of 14 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/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 3 of 14 Question Answer Marks 1(a) Description of Data Item Suitable Identifier Name The temperature of the patient PatientTemperature The temperature of the room RoomTemperature The patient identification number PatientID The name of the nurse taking the measurement NurseName The above are examples only. Names must be meaningful and unambiguous Items 1 and 2 must have suitable prefix / suffix (i.e. not just 'temp') 4 1(b)(i) Expression Evaluates to "Mon" & MID(MyGreeting, 10, 2) "Month" AgeInYears + ASC(MyInitial) 94 INT(MyInitial) ERROR MOD(Weight * 2, 10) 1 Maried AND (NOT Children) FALSE 5 1(b)(ii) Variable Data type MyGreeting STRING MyInitial CHAR AgeInYears INTEGER Weight REAL Married BOOLEAN One mark per answer Alternative appropriate data types acceptable 5 Question Answer Marks 2(a)(i) • Indentation • Blank lines / white space • Capitalisation of keywords • Meaningful identifier names 4 2(a)(ii) • Comments 1

Mark scheme, page 4

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 4 of 14 Question Answer Marks 2(b) Feature Answer A line containing an example of an assignment statement 08,12,13,19 A line containing the start of a repetition block 10 A line containing the end of a repetition block 23 The line containing the start of a selection statement 15 The number of parameters of the MID function 3 The boolean operator used AND The number of local variables 4 The number of function calls from within StringClean() resulting from the call: NewString ← StringClean("Me") 5 The number of a line containing an unneccessary statement 06 9

Mark scheme, page 5

9 © Q 9608/21 © UCLES 2018 Question 3 One mark 1 STAR 2 promp 3 decisi 4 calling 5 decisi 6 calling 7 decisi 8 both o Cambridg for: RT and END pt and input on box che g GetTemp on box com g Alarm() on box com output mess ge Internatio P D / STOP t of Sensor cking that S with Senso mparing Tem mparing Tem sages onal AS/A L PUBLISHED Page 5 of 14 Answer rID (allow a SensorID i orID as pa mp > HighT mp < LowTe Level – Mar D r alt name) is between rameter Temp emp k Scheme 1 & 10 Ma ay/June 201 Mark 18 ks 8

Mark scheme, page 6

9 © Q 9608/21 © UCLES 2018 Question 3 ALTERNA Mark as fo 1 One m 2 One m 3 One m 4 One m 5 One m 6 One m 7 One m 8 One m Cambridg ATIVE SOLU ollows: mark for STA mark for pro mark for dec mark for cal mark for dec mark for cal mark for two mark for bot ge Internatio P UTION USIN ART and EN ompt and inp cision box c ling GetTem cision box C ling Alarm o correct CA th output me onal AS/A L PUBLISHED Page 6 of 14 Answer NG 'CASE' ND / STOP put of Sens checking tha mp with Sen CASE Temp () ASE conditio essages Level – Mar D r P sorID (allow at SensorI nsorID as p ons k Scheme w alt name) ID is betwee parameter Ma ) en 1 & 10 ay/June 201 Mark 18 ks 8

Mark scheme, page 7

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 7 of 14 Question Answer Marks 4(a) Features: • The hierarchy of modules • The parameters that are passed between modules // the interface between the modules • The sequence of module execution One mark per item 3 4(b) Mark as follows: One mark for top box One mark for both lower boxes One mark for diamond 'decision' symbol One mark for each parameter (3 parameters) 6 Question Answer Marks 5(a) Details are saved after the program ends // after the computer is switched off 1 5(b) Two from the following examples: • Context-sensitive help • Syntax checking (on entry) • Automatic indentation • Type checking (Parameter checking) • PrettyPrinting • Highlight structure blocks (e.g. selection, iteration) • Highlight any undeclared variables • Highlight any unassigned variables Max 2 ItemProcess AddToList RemoveFromList RetFlag InString InString

Mark scheme, page 8

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 8 of 14 Question Answer Marks 5(c) 'Pseudocode' solution included here for development and clarification of mark scheme. Programming language solutions appear in the Appendix. PROCEDURE AddNewScores() DECLARE FileData : STRING DECLARE ScoreDate : STRING DECLARE MembershipNumber : STRING DECLARE Score : STRING OUTPUT "Input the date for the scores" INPUT ScoreDate OPENFILE "ScoreDetails.txt" FOR APPEND OUTPUT "Input the Membership number" INPUT MembershipNumber WHILE NOT MembershipNumber = "" OUPUT "Input the score" INPUT Score WHILE (INT(SCORE) < 50) OR (INT(SCORE) > 99) OUTPUT "Input a valid score from 50 to 99" INPUT Score ENDWHILE FileData = MembershipNumber & ScoreDate & Score WRITEFILE "ScoreDetails.txt", FileData OUTPUT "Input the Membership number" INPUT MembershipNumber ENDWHILE CLOSEFILE("ScoreDetails.txt") ENDPROCEDURE 1 mark for each of the following: 1 Declare MembershipNumber as STRING and Score as INTEGER / STRING (commented in Python) 2 Prompt and Input of ScoreDate 3 Open ScoreDetails.txt in APPEND mode 4 Prompt and Input of MembershipNumber in a loop 5 (Outer) loop terminated when MembershipNumber = "" 6 Input Score and loop until valid 7 Form the text string from the three variables 8 Write the text string to the file 9 Close the file 9

Mark scheme, page 9

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 9 of 14 Question Answer Marks 6(a)(i) • The array is 1D • 1 is the lower bound • 5 is the upper bound • size of array / number of elements = 5 Max2 6(a)(ii) • subscript / index 1 6(b) FUNCTION Lighten() RETURNS BOOLEAN DECLARE OldPixelValue : INTEGER DECLARE NewPixelValue : INTEGER DECLARE PixelTemp : REAL DECLARE BurnFlag : BOOLEAN DECLARE i : INTEGER DECLARE j : INTEGER BurnFlag ← FALSE FOR i ← 1 TO 8 FOR j ← 1 TO 8 OldPixelValue ← Picture[i, j] PixelTemp ← OldPixelValue * 1.1 NewPixelValue ← INT(PixelTemp) IF NewPixelValue >= 255 THEN NewPixelValue ← 255 BurnFlag ← TRUE ENDIF Picture[i, j] ← NewPixelValue ENDFOR ENDFOR RETURN BurnFlag ENDFUNCTION 1 mark for each of the following: 1 Function heading as above and ending 2 Declare and initialise local variable for return BOOLEAN / other mechanism to record 'burnt out' 3 Declare local variables for loop counters 4 Correct nested loops 5 Accessing element from array 6 Calculating new value and convert to an INTEGER 7 Comparing new value with 255 and if greater: 8 «limit to 255 and assign to original element 9 «Set flag / other mechanism if limit applied (Only change once) 10 Return a BOOLEAN (following conversion if other mechanism used) MUST WORK MAX8

Mark scheme, page 10

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 10 of 14 Question Answer Marks 7 'Pseudocode' solution included here for development and clarification of mark scheme. Programming language solutions appear in the Appendix. FUNCTION ProcessMarks(Mark: ARRAY[1:20] OF INTEGER) RETURNS INTEGER DECLARE Highest : INTEGER DECLARE Average as REAL DECLARE Total as INTEGER DECLARE Position as INTEGER Total ← 0 Highest ← Mark[1] //The highest mark is the first one Position ← 1 FOR i ← 1 to 20 Total ← Total + Mark[i] IF Mark[i] > Highest THEN Highest ← Mark[i] Position ← i ENDIF ENDFOR Average ← Total/20 Output ("The average mark is " & Average & " and the highest mark is " & Highest) RETURN Position ENDFUNCTION 1 mark for each of the following: 1 Correct Function heading (including Mark as parameter) and ending 2 Declare local variable for Highest and initialise 3 Loop structure (1 to 20 or 0 to 19) 4 Comparison with current Highest 5 «Assign new Highest 6 Calculate Average 7 Output message including both variables and explanatory text 8 Return value of index Max7 *** End of Mark Scheme – example program code solutions follow ***

Mark scheme, page 11

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 11 of 14 Appendix Program Code Example Solutions Q5(c) Visual Basic Sub AddNewScores() Dim FileData As String Dim MembershipNumber As String Dim Score As Integer Dim ScoreDate As String Dim FileHandle As IO.StreamWriter FileHandle = New IO.StreamWriter("ScoreDetails.txt") Console.WriteLine("Input the date for the scores") ScoreDate = Console.ReadLine() Console.WriteLine("Input the Membership number") MembershipNumber = Console.ReadLine() Do While MembershipNumber <> "" Console.WriteLine("Input the score") Score = Console.ReadLine() Do While Score < 50 Or Score > 99 Console.WriteLine("Input a valid score from 50 to 99") Score = Console.ReadLine() Loop FileData = MembershipNumber & ScoreDate & Str(Score) FileHandle.WriteLine(FileData) Console.WriteLine("Input the Membership number") MembershipNumber = Console.ReadLine() Loop FileHandle.Close() End Sub

Mark scheme, page 12

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 12 of 14 Python def AddNewScores(): #ScoreDate as string #MembershipNumber as string #Score as integer #FileHandle as text file FileHandle = open("ScoreDetails.txt", "a") ScoreDate = str(input("Input the date for the scores")) MembershipNumber = str(input("Input the Membership number")) while MembershipNumber != "": Score = int(input("Input the score")) while Score < 50 or Score > 99: Score = int(input("Input a valid score from 50 to 99")) FileData = MembershipNumber + ScoreDate + str(Score) FileHandle.write(FileData) MembershipNumber = str(input("Input the Membership number")) FileHandle.close Pascal procedure AddNewScores; var FileData, ScoreDate, MembershipNumber: String; Score: Integer MyFile: text; begin assign(MyFile,'ScoreDetails.txt'); append(MyFile); writeln('Input the date for the scores'); readln(ScoreDate); writeln('Input the Membership number'); readln(MembershipNumber); while MembershipNumber <> '' do begin writeln('Input the score'); readln(Score); while (Score < 50) or (Score > 99) do begin writeln('Input the score'); readln(Score); end; FileData := MembershipNumber + ScoreDate + IntToStr(Score); write(MyFile, FileData); writeln('Input the Membership number'); readln(MembershipNumber); end; close (MyFile); end;

Mark scheme, page 13

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 13 of 14 Q7 Visual Basic Function ProcessMarks(ByVal Mark() As Integer) As Integer Dim Highest As Integer Dim Average As Single Dim Total As Integer Dim Position As Integer Dim i As Integer Total = 0 Position = 1 Highest = Mark(1) For i = 1 To 20 Total = Total + Mark(i) If Mark(i) > Highest Then Highest = Mark(i) Position = i End If Next Average = Total / 20 Console.WriteLine ("The average mark is " & Average & _ " and the highest mark is " & Highest) Return Position End Function Python def ProcessMarks (mark): #highest, i, position, total as integer #average as real highest = mark[0] total = 0 position = 0 for i in range(0,20): total = total + mark[i] if mark[i] > highest: highest = mark[i] position = i average = total/20 print('The average mark is ' + str(average) + \ ' and the highest mark is ' + str(highest)) return position

Mark scheme, page 14

9608/21 Cambridge International AS/A Level – Mark Scheme PUBLISHED May/June 2018 © UCLES 2018 Page 14 of 14 Pascal function ProcessMarks (mark:array of integer):integer; var highest, total, position, i: integer; average: real; begin highest := mark[1]; total := 0; position := mark[1]; for i := 1 to 20 do begin total := total + mark[1]; if mark[i] > highest then begin highest := mark[i]; position := i; end; end; average := total / 20; writeln ('The average mark is ', average, ' and the highest mark is ', highest); ProcessMarks := position; end;

What you needed in this session

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

A49/75
B43/75
C35/75
D27/75
E20/75