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

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

Mark scheme12 pages

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

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

Paper as text

Question paper, page 1

This document consists of 16 printed pages. DC (LK/SG) 106693/4 © UCLES 2016 [Turn over Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level * 7 9 1 1 8 0 0 7 3 8 * COMPUTER SCIENCE 9608/23 Paper 2 Fundamental Problem-solving and Programming Skills May/June 2016 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/16 © UCLES 2016 There is an Appendix on the last page. Some questions will refer you to this information. 1 The items in the table below are statements from a program in a generic programming language. For the built-in functions list, refer to the Appendix on the last page. (a) (i) Show what type of programming construct each statement represents. Complete the table by putting a tick (✓) in the appropriate column for each item. Item Statement Selection Iteration Assignment 1 WHILE DegF > 37.5 2 MyName = "Gordon" 3 DegF = INT(DegF) 4 ENDIF 5 CASE OF MyFavourite 6 UNTIL x = 5 [6]

Question paper, page 3

3 9608/23/M/J/16 © UCLES 2016 [Turn over (ii) State the purpose of each statement in the table in part (a)(i). Do not use mathematical symbols in your descriptions. Item Purpose of statement 1 … … 2 … … 3 … … 4 … … 5 … … 6 … … [6] (iii) Evaluate the following expressions when MyString has the value "Corrective Maintenance": Expression Evaluates to 'P' & MID(MyString, 13, 4) RIGHT(MID(MyString, 6, 10) ,4) [2]

Question paper, page 4

4 9608/23/M/J/16 © UCLES 2016 2 The engine management system of a car includes an energy-saving facility. When certain conditions are met, this facility will automatically stop the engine. The system is to be software-based. It will include a subroutine, EnergySaver, which repeatedly takes data from sensors in the car. The subroutine decides whether or not to set the EngineStop value. The table of identifiers used by this subroutine is shown below. (a) Complete the identifier table below by stating the data types. Identifier Data type Description Accelerator … Accelerator pedal position Values: 0 to 100 in steps of 1 Meaning: 0: none (not pressed) 100: maximum (fully pressed) EngineTemp … Engine temperature in °C (-50 to +150 stored to 1 decimal place) NormalTemp … Normal engine temperature in °C Whole number; typical value 90 Speed … Road speed of car (in km/hr) Values: 0 to 200 in steps of 1 EngineStop … Value used to signal engine must be stopped Possible values: TRUE: stop engine FALSE: run engine [5] The condition for stopping the engine is that all three of the following are true: • Accelerator is not pressed • Engine temperature is normal or above • Car speed is zero

Question paper, page 5

5 9608/23/M/J/16 © UCLES 2016 [Turn over The initial design stage will produce a prototype of EnergySaver, with a user interface. The structured English for this is: 1. INPUT value for accelerator pedal position 2. INPUT value for engine temperature 3. INPUT value for normal engine temperature 4. INPUT value for car speed 5. EVALUATE engine stopping condition 6. IF stopping condition satisfied SET engine stop value to TRUE 7. IF stopping condition not satisfied SET engine stop value to FALSE 8. OUTPUT message indicating engine stop value (b) Write the pseudocode equivalent of the structured English. Use the identifiers from the table in part (a). For the built-in functions list, refer to the Appendix on the last page. … … … … … … … … … … … … … … …[6]

Question paper, page 6

6 9608/23/M/J/16 © UCLES 2016 3 String encryption was implemented using a simple character-substitution method. A function, Decrypt, is needed to reverse the encryption process and return the original character. The encryption uses the 7-bit ASCII value for each character. This value is used as an index for a 1D array, Lookup, which contains the substitute characters. Lookup contains an entry for each of the ASCII characters. This function, Decrypt, will accept two parameters, a single character, CipherChar, and the 1D array, Lookup. The steps involved in Decrypt are follows: • Search for the character in the array • Note the index value where the character is found (the index value is the ASCII value of the original character) • Use the index value to obtain the original character (a) The first attempt at writing the pseudocode for this function is shown below. Complete the pseudocode. For the built-in functions list, refer to the Appendix on the last page. FUNCTION Decrypt(… , …) RETURNS CHAR DECLARE Found : … DECLARE … : INTEGER DECLARE OriginalChar : CHAR Index 1 // … Found FALSE //search for CipherChar in Lookup: WHILE … //compare CipherChar with this array element: IF … THEN …//Set the flag ELSE Index …//Move to next array element ENDIF ENDWHILE //dropped out of loop so must have found CipherChar: …//convert Index to original character RETURN … ENDFUNCTION [11]

Question paper, page 7

7 9608/23/M/J/16 © UCLES 2016 [Turn over Question 3 continues on page 8.

Question paper, page 8

8 9608/23/M/J/16 © UCLES 2016 (b) A program is to be written to output part of the Lookup array. The design of the algorithm is shown below. It may be assumed that the characters output from Lookup are all printable. START Input StartIndex and NumberToOutput Produce OriginalChar from Index (using built-in function) Assign current array element to CipherChar Increment Index Output message line (see examples on the next page) End of loop? STOP YES NO Index StartIndex Loop

Question paper, page 9

9 9608/23/M/J/16 © UCLES 2016 [Turn over For example, for the input of 65 and 3, the output will be: Index 65: Character A has substitute character Y Index 66: Character B has substitute character Q Index 67: Character C has substitute character F Write program code to implement the flowchart design. In addition to the Lookup array, assume that the following variables have been declared: StartIndex, NumberToOutput, Index Programming language … … … … … … … … … … … … … … … [6]

Question paper, page 10

10 9608/23/M/J/16 © UCLES 2016 4 (a) Name two features of your chosen high-level programming language that support the implementation of a modular design. 1 … 2 … [2] (b) (i) The structure chart shows part of the design of a program for an online shopping system. The user has already added a number of products to their virtual basket. Draw on the chart, the symbol to show that the process of modifying the basket contents may be iterated (repeated). Modify Basket Contents Input product data Change product quantity Remove product F D E C A B [1] (ii) Each arrow in the structure chart above represents a parameter. The table below shows the three data items that the six parameters pass between modules. Tick (✓) to match each parameter to the correct data item. Data item Parameter A B C D E F Product ID Quantity Flag Value – indicating operation success or fail [4]

Question paper, page 11

11 9608/23/M/J/16 © UCLES 2016 [Turn over 5 Claudia stores her large collection of music CDs in different places. Claudia wants to record where she stores each CD. She decides to write a program to do this. Data items for a typical CD are: Title: Kind of Green Artist: Miles Coltrane Location: Rack3-23 The data is to be stored in a text file, MyMusic. Each line of the text file will be a string, formed by concatenating the three data items. Before concatenation, the title and artist will each be made into a fixed-length string of 40 characters. Space characters may need to be added to each data item. The location is always 8 characters long. (a) (i) Explain the benefit of making the stored data into fixed-length strings. … … … … State a drawback of this file design. … … [3]

Question paper, page 12

12 9608/23/M/J/16 © UCLES 2016 (ii) When Claudia buys a new CD, the CD data must be added to the existing file, MyMusic. She has written a procedure in pseudocode. This has the following file-handling statements: OPENFILE "MyMusic" FOR WRITE WRITEFILE "MyMusic", OutputString CLOSEFILE "MyMusic" There is a problem with the logic of this pseudocode. State the problem. … … Identify the effect it will have if the final code is implemented in this way. … … Give a possible solution. … … [3] (b) Claudia needs to output a list of all the CDs in a particular location. She designs a procedure, OutputLocationList, to do this. She also chooses the following identifiers: Identifier Data type CDTitle STRING CDArtist STRING CDLocation STRING The procedure will: • prompt for the name of the location • input the location (such as “Rack3-23”) • search the file for all CDs at this location • output the title and artist of each CD found • output the total number of CDs found at that location (such as “17 CDs found”)

Question paper, page 13

13 9608/23/M/J/16 © UCLES 2016 [Turn over Write program code for the procedure OutputLocationList. 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 … … … … … … … … … … … … … … … … … … … … … [10]

Question paper, page 14

14 9608/23/M/J/16 © UCLES 2016 6 A string-handling function has been developed. For the built-in functions list, refer to the Appendix on the last page. The pseudocode for this function is shown below. FUNCTION SF(ThisString : STRING) RETURNS STRING DECLARE x : CHAR DECLARE NewString : STRING DECLARE Flag : BOOLEAN DECLARE m, n : INTEGER Flag TRUE NewString "" m LENGTH(ThisString) FOR n 1 TO m IF Flag = TRUE THEN x UCASE(MID(ThisString, n, 1)) Flag FALSE ELSE x LCASE(MID(ThisString, n, 1)) ENDIF NewString NewString & x IF x = " " THEN Flag TRUE ENDIF ENDFOR RETURN NewString ENDFUNCTION (a) (i) Complete the trace table below by performing a dry run of the function when it is called as follows: SF("big BEN") n x Flag m NewString [4]

Question paper, page 15

15 9608/23/M/J/16 © UCLES 2016 [Turn over (ii) Describe the purpose of function SF. … … … …[2] (b) Test data must be designed for the function SF. (i) State what happens when the function is called with an empty string. … …[1] (ii) The function should be thoroughly tested. Give three examples of non-empty strings that may be used. In each case explain why the test string has been chosen. String … Explanation … … String … Explanation … … String … Explanation … … [3]

Question paper, page 16

16 9608/23/M/J/16 © UCLES 2016 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. Appendix Built-in functions (Pseudocode) In each function below, if the function call is not properly formed, the function returns an error. MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING returns the string of length y starting at position x from ThisString Example: MID("ABCDEFGH", 2, 3) will return string "BCD" LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING returns the leftmost x characters from ThisString Example: LEFT("ABCDEFGH", 3) will return string "ABC" RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING returns the rightmost x characters from ThisString Example: RIGHT("ABCDEFGH", 3) will return string "FGH" CHR(x : INTEGER) RETURNS CHAR returns the character whose ASCII value is x Example: CHR(87) will return 'W' ASC(x : CHAR) RETURNS INTEGER returns the ASCII value of character x Example: ASC('W') will return 87 LCASE(x : CHAR) RETURNS CHAR returns the lower case equivalent character of x Example: LCASE('W') will return 'w' UCASE(x : CHAR) RETURNS CHAR returns the upper case equivalent character of x Example: UCASE('h') will return 'H' INT(x : REAL) RETURNS INTEGER returns the integer part of x Example: INT(27.5415) will return 27

Mark scheme, page 1

® IGCSE is the registered trademark of Cambridge International Examinations. This document consists of 12 printed pages. © UCLES 2016 [Turn over Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/23 Paper 2 Written Paper May/June 2016 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 2016 series for most Cambridge IGCSE®, Cambridge International A and AS Level components and some Cambridge O Level components.

Mark scheme, page 2

Page 2 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2016 9608 23 © Cambridge International Examinations 2016 1 (a) (i) [6] Item Statement Selection Iteration Assignment 1 WHILE DegF > 37.5  2 MyName = "Gordon"  3 DegF = INT(DegF)  4 ENDIF  5 CASE OF MyFavourite  6 UNTIL x = 5  One mark per row Additional ticks in any row cancels that row (ii) [6] Item Purpose of statement 1 (Start of) loop – repeat while DegF greater than 37.5 2 Assign (string) "Gordon" to MyName 3 Assign integer value / whole number part of DegF to DegF 4 End of an IF statement / selection statement 5 Head of CASE / selection statement based on variable MyFavourite 6 End of REPEAT / post-condition loop: repeated until x equals 5 Exact wording not important Explanation must refer to variables or values used in code (except for row 4) (iii) [2] Expression Result 'P' & MID(MyString, 13, 4) "Paint" RIGHT(MID(MyString, 6, 10), 4) "Main" Must have correct case Quotation marks optional

Mark scheme, page 3

Page 3 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2016 9608 23 © Cambridge International Examinations 2016 2 (a) [5] Identifier Data Type Description Accelerator INTEGER Accelerator position Values: 0 to 100 in steps of 1 Meaning: 0 : none (not pressed) 100: maximum (fully pressed) EngineTemp REAL / FLOAT / SINGLE / DOUBLE Engine temperature in °C (–50 to +150 correct to 1 decimal place) NormalTemp INTEGER Normal engine temperature in °C Whole number; typical value 90 Speed INTEGER Road speed of car (in km/hr) Values: 0 to 200 in steps of 1 EngineStop BOOLEAN Value used to signal engine must be stopped Possible values: TRUE: stop engine FALSE: run engine One mark per row Data types as shown

Mark scheme, page 4

P 3 Pag ( ( 2 ge (b) (a) 4 ) M 1 2 3 4 5 6 F E O IN IN IN IN I EN OU Mar 1. 2. 3. 4. 5. 6. FUN D D D I F W E / O R END One NP NP NP NP F ND UT rk F C C C C O (F NCT DEC DEC DEC Ind Fou WHI I E END //d Ori RET DFU e m C UT UT UT UT Ac TH EL DIF PU po ou Corr Corr Corr Corr Outp Fol TI CLA CLA CLA de un // ILE / IF E EN DW dr ig TUR UN mar Cam T A T E T N T S cce HEN E LSE E F UT ints r IN rec rec rec rec put low ON AR AR AR x d /no E / L TH EL DI HI op in RN CT rk f mb Acc Eng Nor Spe ele N Eng E Eng "E s a NP ct I ct s ct T ct E t in win N D RE RE RE ← ← ow Fo co Loo HEN Fo LSE In F LE ppe nal N O IO for brid cel gin rma eed era gin gin Eng as c PUT IF. sec THE ELS ndic ng E Dec Fo In Or 1 F se oun omp oku N oun E nde E ed lCh Ori ON r ea dg le ne al d at ne ne gi circ T s ..T con EN SE cat EN cry oun nde rig FAL ea nd par up nd ex ou har igi ach e I ra Te Te or St St ne cle tat TH nd a sta sta ting DI ypt nd ex gin LSE rc = re [In ← ← ut r ← ina h p nte © ato emp emp r = top top e S d, tem EN and ate ate g E F o t na E h FA C nd ← T ← I o ← al art ern Ca or p p = 0 p ← p ← Sto de men N.. d th eme eme Eng or a (L lC fo AL ip dex TRU Ind f CH Ch t-st nat amb 0 A ← T ← F opp esc nts EL hird ent ent gine as Loo Cha or LSE phe x] UE de lo HR har tate M tio brid AND TRU FAL ped ript s (c LSE d c t t eS tw oku ar Ci E / erC = x oop R(I r em Mar na dge D UE LS d" tion corr E. con top wo up : : : ip // Cha Ci + p s Ind men 1 k S l A e In En E ns rec .E ndit p sep : B I C // a he Fo ar iph 1 so dex nt (s 1 Sch AS/ nter ngi as ct n ND tion pa A BOO INT CHA /st as erC ou w he m x) sho 4 hem /A rnat ine s be nam DIF ns rat ARR OL TE AR tar si Cha und wit rC / / mus ow 4 5 6 me Le tion eTe elo mes F in te s RAY EA GE R rt ign ar d < th Cha / /M st // wn u e eve nal emp ow: s a nclu sta Y, AN ER t w n t in <> th ar Se Mov ha c und el – Ex p and udi tem Ci wit the n TR his et ve ave con der – M xam >= d se ng me iph th e Lo RUE s th to e nve rlin May mina = N equ g fir ents he fi st ooo E ar he o n fo ert ned y/Ju atio Nor ue rst s w erC ir tar oku // rra f ne oun t d an 3 un ons rma nce co with Cha st rt up / N ay la xt nd In nd 3 e 2 s 20 al e) nd hin ar t e in : NOT el ag a Ci nde bo 201 016 Te itio TH : ele nde T F lem arr iph ex old) 16 6 emp on HEN C eme ex Fo me ray he to ) p A (or N a HA ent x un nt y e rC o o AND r eq and AR) t nd t: el Cha or S D qui d EL R in em ar: ig Syl 9 Sp iva LS RET n t men : gin llab 960 ee alen E) TUR the nt nal bu 08 ed nt n RN e a l c s = nes NS arr ch P 0 ste CH ra ar Pa 2 d I HAR ay ac pe 23 IFs [ R // cte er [6 s) [11 / er 6] ]

Mark scheme, page 5

P 4 Pag ( ( 2 ge (b) (a) 5 ) 'P s M 1 2 3 4 5 6 • • • Ps sch Mar 1. 2. 3. 4. 5. 6. • • • eu hem I I F E rk Tw W A A O .. F A U C udo me NP NP OR O ND po wo Wor Ass Ass One .a s un Abil Use Cam oco e. P PUT PUT R I Or Ci OUP DFO ints o IN rkin ign ign e m sec ctio ity e of mb ode Pro T S T N Ind rig iph PUT OR s a NP ng nme nme mar con ons to f lo brid e' s ogr Sta Num dex gin her T as c UT loo ent ent rk fo nd s / pa oca dg sol ram art mbe x ← na rCh (" " circ T st op t (u t (u or ma Pr ass l / e I lut mm tI er ← lC ha In h cle tate us usi usi OU ark roc s pa glo nte © ion ming nd To St ha r de as d, em ing ng ng UT k if ced ara oba ern Ca n in g l dex oOu ta ar ← ex s s de men g In co co PU OU ure ame al v nat amb ncl an x utp rt ← L " sub esc nts nde orre orre UT UT es ete var M tio brid lud ngu put tIn ← C Loo & bst ript ex ect ect of TPU ers iab Mar na dge ded uag t nde CHR oku I ti tion (al va va a s UT be bles k S l A e In d h ge ex R(I up nd tu ns low alue alue stri str etw s Sch AS/ nter her ex t In [I dex ute as w a es es ng ring wee hem /A rnat re f xam o de nd x & e c s be alte of of co g is en m 1 me Le tion for mp St x) dex & " cha elo erna Ind Ind om s c mo e eve nal r de le s tar x] ": ara ow: ativ dex dex bin com odu el – Ex eve so rtI C ac ve x o x o nin mpl ules 3 4 – M xam elo lut Ind ha te so or o or o g t ete s May mina opm tio de ara er olut oth oth ext ely y/Ju atio me ns x act " tion er er t a co un ons ent ap + ter & ns va va nd orre e 2 s 20 an ppe Nu r C inc aria aria va ect 201 016 nd ear umb " ip clud able able aria 16 6 cla r in be & he din e) e) able arif n th rT Or erC g s es fic he oO rig Cha sep ... S ati Ap Out gin ar par Syl 9 ion pp tpu na ) rate llab 960 n o en ut lC e lo 6 bu 08 f th ndix - Cha oop s he x. 1 ar p c P m & cou Pa 2 ark unte 5 pe 23 k er) er [6 [2 6] 2]

Mark scheme, page 6

P Pag ( ge (b) 6 ) ( (i (i) i) O P Q F o M R R R C One Prod Qua lag pe Mar Row Row Row Cam e m duc anti g V rat rk a w 1 w 2 w 3 mb mar ct I ity Valu tion as f : O : O : O brid rk fo Da ID ue n s foll One One One dg or ata – i ucc low e m e m e m e I co a Ite nd ces ws: mar mar mar nte © rre em ica ss rk f rk f rk f ern Ca ect m atin or for for for nat amb arr ng fai tic D C M tio brid row il ck i OR AN Mar na dge w a n A R E ND k S l A e In as s A A E (m F Sch AS/ nter sho AND mu hem /A rnat ow A  D B ust me Le tion n – B, o be e eve nal – a one e op el – Ex cce B  e m ppo – M xam ept B  ma osi May mina t e P rk te y/Ju atio ithe Par C  for of un ons er am C  r D Ro e 2 s 20 dir met O ow 201 016 rect ter D  ( R E 1) 16 6 tio D  ) E n E (  S ) Syl 9 llab 960 F  bu 08 s Pa 2 pe 23 er [1 [4 ] 4]

Mark scheme, page 7

Page 7 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2016 9608 23 © Cambridge International Examinations 2016 5 (a) (i) Explanation: [Max 3] • Easier to separate the two strings // to retrieve / search for / edit (text relating to a CD) • Obvious where CDTitle ends and CDArtist begins Drawback: • Takes up more / unnecessary space in the file • If the string is bigger than 40 characters then data will be lost // string length is limited • The additional spaces will need to be removed before strings can be used One mark per bullet (ii) Problem: File mode = WRITE / file is opened for writing // by explanation [3] Effect: All existing file lines / contents / data will be overwritten / deleted / lost Solution: WRITE should be changed to APPEND (allow meaningful example) Allow first two mark points to be interchanged – read as one paragraph.

Mark scheme, page 8

Page 8 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2016 9608 23 © Cambridge International Examinations 2016 (b) 'Pseudocode' solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. [Max 10] PROCEDURE OutputLocationList() DECLARE CDTitle : STRING DECLARE CDArtist : STRING DECLARE CDSearch : STRING DECLARE FileData : STRING DECLARE Total : INTEGER DECLARE FileData : STRING Total ← 0 OPENFILE "MyMusic" FOR READ OUTPUT "Input Location" INPUT CDSearch WHILE NOT EOF("MyMusic") READFILE ("MyMusic", FileData IF RIGHT(FileData, 8) = CDSearch THEN CDTitle ← LEFT(FileData, 40) CDArtist ← MID(FileData(41, 40) OUPUT (CDTitle & " – " & CDArtist) Total ← Total + 1 ENDIF ENDWHILE OUTPUT (Total & " CDs found" CLOSEFILE("MyMusic") ENDPROCEDURE One mark for each of the following: • Procedure heading and ending • Declaration AND initialisation of variable used as counter (Total above) • Prompt and input of location to search for CDSearch (or other name) • Open file for reading (Allow MyMusic or MyMusic.txt) • Working conditional loop structure including test for EOF The following points must be present inside a loop • Read a line from the file (or read complete file in one e.g. as list) • Isolate 8 chars representing location and compare with CDLocation • Extract strings representing CDTitle and CDArtist • Output CDTitle and CDArtist (separator optional) if correct location found • Increment Total if correct location found The following points must be present after a loop • Output message including number of CDs found at location (Total) • Close file

Mark scheme, page 9

P 6 Pag ( ( ge (a) (b) 9 ( (i ) ( (i (i) i) (i) i) O • • • • (T • • • E • • • • • • • O C One To xa One Cam n – 1 2 3 4 5 6 7 e m Ar Le Ig Al ret Th Th Th mp St St St St St St St e m mb mar rrow ette no low tur he he he ple trin trin trin trin trin trin trin mar brid rk p ws er c re w “ n a firs rem fun s o ngs ngs ngs ngs ng w ngs ngs rk fo dg per s in cas qu “ o a st st c ma nct of s s w s w s w s in wit s w s w or e I x ‘B ‘ ‘g ‘▽ ‘B ‘e ‘n r co dic se ota or ▽ trin cha aini tion suit ith ith ith “re h o ith ith ea nte © x B i’ g’ ▽’ B’ e’ n’ orre cate mu atio ▽ fo ng w ara ng n o tab all all firs eve only m nu ach ern Ca ect e r ust on or s wh acte ch pe ble l ca l lo st l ers y o ulti um st nat amb t co req be sy spa here er o har rat tes api owe lett se” one iple be rin M tio brid F T FA T FA olu uir e a mb ace e:) of e rac tes st s tal er c ters fo e w e s rs g e Mar na dge Fla TRU AL TRU AL mn red s s bol e s eac cter s no stri s cas s o rm word spa / sy exa k S l A e In ag UE SE UE SE n (c se sho sym ch rs ( orm ing se of w at d ace ym am Sch AS/ nter E E col equ own mbo wo (of mal gs: wor – i s mbo ple hem /A rnat lum uen n ol ord ea lly rds .e. ols e p me Le tion mn nce d is ach // r s al fir plus e eve nal m 7 ns 3 e (i ca h w retu lrea rst s s el – Ex m 7 3 a .e. apit word urn ady lett sup – M xam and “B tali d) a ns a y c ter ppo May mina N d 4 B” c ise are an cap rs lo ortin y/Ju atio New “ “B “B co can ed / e m ‘em pita ow ng un ons wS “ “ “B “B “Bi “Big Big Big▽ oun n’t / m mad mp alise wer ex e 2 s 20 tr “” B” Bi” Big” ig▽ g▽B g▽B ▽Be nt be mad de pty ed ca xpla 201 016 ing ” “ B” Be” en” as in de u low str (i.e ase ana 16 6 g ” 1) ro upp wer ring e. e, th atio ) ow per r ca g’ in c he on. bef r ca ase cor res S for ase e rre st u Syl 9 re T e // ct up llab 960 TR / by for pe bu 08 RUE y e rma r c s E) exp at) ase P plan e Pa 2 nat pe 23 tion er [4 [2 n [1 [3 4] 2] ] 3]

Mark scheme, page 10

Page 10 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2016 9608 23 © Cambridge International Examinations 2016 Appendix – Program Code Example Solutions Q3 (b): VB.NET Console.WriteLine("Enter start position") StartIndex = Console.ReadLine() Console.WriteLine("Enter how many") NumberToOutput = Console.ReadLine() For Index = StartIndex To StartIndex + NumberToOutput - 1 OriginalChar = Chr(Index) CipherChar = Lookup(Index) Console.WriteLine("Index " & Index & ": Character " & OriginalChar & " has substitute character " & CipherChar) Next Index Q3 (b): Pascal Writeln('Enter start position'); Readln(StartIndex); Writeln('Enter how many'); Readln(NumberToOutput); For index := StartIndex To StartIndex + NumberToOutput – 1 Do Begin OriginalChar := chr(index); CipherChar := Lookup[index]; writeln("Index " + index + ": Character " + OriginalChar + " has substitute character " & CipherChar); end; Q3 (b): Python startIndex = int(input("enter start position")) numberToOutput = int(input("enter how many")) for index in range(startIndex, (startIndex + numberToOutput)) : OriginalChar = chr(index) CipherChar = Lookup[index] print("Index " + (index) + ": Character " + OriginalChar + " has subst char " + CipherChar)

Mark scheme, page 11

Page 11 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2016 9608 23 © Cambridge International Examinations 2016 Q5 (b): VB.NET A StreamReader() solution: Sub OutPutLocationList() Dim Total As Integer Dim FileData As String Dim ObjReader As IO.StreamReader ObjReader = New IO.StreamReader("C:\MyMusic.txt") Dim CDLocation As String Dim CDTitle As String Dim CDArtist As String Total = 0 Console.WriteLine("Input location to search ") CDSearch = Console.ReadLine Do While ObjReader.Peek <> -1 FileData = ObjReader.ReadLine() If Right(FileData, 8) = CDLocation Then CDTitle = Left(FileData, 40) CDArtist = Mid(FileData, 41, 40) Console.WriteLine(CDTitle & " " & CDArtist) Total = Total + 1 End If Loop Console.WriteLine(Total & " CDs were found") ObjReader.Close() End Sub A legacy FileOpen() solution: Sub OutPutLocationList() Dim Total As Integer Dim FileData As String FileOpen (1, "C:\MyMusic.txt", OpenMode.Input) Dim CDLocation As String Dim CDTitle As String Dim CDArtist As String Total = 0 Console.WriteLine("Input location to search ") CDSearch = Console.ReadLine Do While NOT EOF(1) Input(1, FileData) If Right(FileData, 8) = CDSearch Then CDTitle = Left(FileData, 40) CDArtist = Mid(FileData, 41, 40) Console.WriteLine(CDTitle & " " & CDArtist) Total = Total + 1 End If Loop Console.WriteLine(Total & " CDs were found") FileClose(1) End Sub

Mark scheme, page 12

Page 12 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2016 9608 23 © Cambridge International Examinations 2016 Q5 (b): Pascal procedure OutputLocationList; var FileData, CDLocation, CDTitle, CDArtist : String; CDFile : Textfile; Total : Integer; Begin Total := 0; Writeln('Input location to search '); Readln(CDSearch); AssignFile(CDFIle, 'MyMusic.txt'); Reset(CDFile); While not eof(CDFile) Do Begin readln(CDFile, FileData); If copy(FileData, 80, 8) = CDSearch Then Begin CDTitle := copy(FileData, 1, 40); CDArtist := copy(FileData, 41, 40); Writeln(CDTitle + ‘ : ‘ + CDArtist); Total := Total + 1; End; End; Writeln(Total + ‘ CDs were found’) CloseFile(CDFile); End Q5 (b): Python #total : Integer #CDSearch, LineOfText, LineString : String Def OutPutLocationList(): FileHandle = open("MyMusicPy.TXT", "r") total = 0 CDSearch = input("Enter location to search") LineOfText = FileHandle.readline() while len(LineOfText) > 0: LineString = LineOfText[80:87] #extact last 8 characters (location) if LineString == CDSearch: total = total+1 CDTitle = LineOfText[0:39] #extract CD title CDArtist = LineOfText[40:79] #extract CD artist print(CDTitle + ": " + CDArtist) LineOfText = FileHandle.readline() #read next line print("There are " + str(total) + " in that location") FileHandle.close()

What you needed in this session

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

A50/75
B39/75
C32/75
D26/75
E20/75