Cambridge A Level Computer Science 9608 — 2015 May/June Paper 2 · Variant 3
9608/23/M/J/15 · 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.
Question paper16 pages
















Mark scheme9 pages
Answers below. Sit the paper first if you are practising.









Paper as text
Question paper, page 1
This document consists of 14 printed pages and 2 blank pages. DC (LK/JG) 95389/4 © UCLES 2015 [Turn over * 9 0 6 6 0 7 6 3 4 2 * COMPUTER SCIENCE 9608/23 Paper 2 Fundamental Problem-solving and Programming Skills May/June 2015 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. Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level
Question paper, page 2
2 9608/23/M/J/15 © UCLES 2015 Throughout the paper you will be asked to write either pseudocode or program code. Complete the statement to indicate which high-level programming language you will use. Programming language … 1 Horses are entered for a horse race. A horse may have to carry a penalty weight in addition to the rider. This weight is added to the saddle. The penalty weight (if any) depends on the number of wins the horse has achieved in previous races. The penalty weight is calculated as follows: Number of previous wins Penalty weight (kg) 0 0 1 or 2 4 Over 2 8 A program is to be written from the following structured English design. 1 INPUT name of horse 2 INPUT number of previous wins 3 CALCULATE penalty weight 4 STORE penalty weight 5 OUTPUT name of horse, penalty weight (a) Complete the identifier table showing the variables needed to code the program. Identifier Data type Description [3] (b) Line 3 in the algorithm above does not give the detail about how the race penalty weight is calculated; this step in the algorithm must be expressed in more detail. (i) The algorithm above currently has five stages. One technique for program design is to further break down, where required, any stage to a level of detail from which the program code can be written. Name this technique. …[1]
Question paper, page 3
3 9608/23/M/J/15 © UCLES 2015 [Turn over (ii) Write pseudocode for the given structured English design. … … … … … … … … … … … … … … …[5]
Question paper, page 4
4 9608/23/M/J/15 © UCLES 2015 2 (a) Two operators available in a programming language are DIV and MOD. They perform integer arithmetic as follows: Expression Explanation X DIV Y Computes the number of times Y divides into X X MOD Y Computes the remainder when X is divided by Y Calculate the value of the variables shown for the following code fragments. Code Variable (i) NumberLeftOver 37 MOD 10 NumberLeftOver … [1] (ii) Quantity 208 BoxSize 100 NumberOfBoxes Quantity DIV BoxSize Temp (Quantity MOD BoxSize) + 1 NumberOfBoxes … Temp … [2] (b) Bank customers withdraw money from their account at a cash dispenser machine using their bank card. The machine operates as follows: • it can dispense the following notes: o $50 o $20 o $10 • the maximum amount for a single withdrawal is $500 When a customer withdraws money, they enter the amount to withdraw. (This must be a multiple of $10). The machine will always dispense the least possible number of notes. A program is designed for the machine to process a withdrawal. The following variables are used: Identifier Data type Description Amount INTEGER Amount to withdraw entered by the user FiftyDollar INTEGER Number of $50 notes to dispense TwentyDollar INTEGER Number of $20 notes to dispense TenDollar INTEGER Number of $10 notes to dispense Temp INTEGER Used in the calculation of the number of each note required
Question paper, page 5
5 9608/23/M/J/15 © UCLES 2015 [Turn over (i) The following four tests have been designed. Complete the test data table showing the expected results with comments. Input value Output Comment Amount FiftyDollar TwentyDollar TenDollar 70 1 1 0 Least possible number of notes 85 130 600 [3] (ii) Complete the pseudocode. INPUT … IF Amount > 500 THEN OUTPUT "Refused – amount too large" ELSE … THEN OUTPUT "Refused - not a multiple of $10" ELSE FiftyDollar Amount DIV 50 Temp … TwentyDollar … Temp … … ENDIF ENDIF [5]
Question paper, page 6
6 9608/23/M/J/15 © UCLES 2015 3 A flooring company provides for each customer an estimated price for a new job. Each job is given a Job ID. The job cost is calculated from the length (nearest metre) and width (nearest metre) of the room. The process for calculating the price is as follows: • the floor area is calculated with 18% added to allow for wastage • the job cost is calculated at $50 per square metre The structure chart shows the modular design for a program to produce a new job cost. Input job data Calculate job cost Send estimate to customer Produce flooring job cost Width JobID CustomerName JobCost D A B C E Length (i) Give the data items corresponding to the labels A to E in the structure chart. A … B … C … D … E … [5]
Question paper, page 7
7 9608/23/M/J/15 © UCLES 2015 [Turn over (ii) The procedure below is one of the modules shown on the structure chart. Parameters can be passed ‘by value’ or ‘by reference’. Complete the procedure header below showing for each parameter: • its parameter passing mechanism • its identifier • its data type PROCEDURE CalculateJobCost( … … … … ) JobCost (Length * Width * 1.18) * 50 ENDPROCEDURE [5]
Question paper, page 8
8 9608/23/M/J/15 © UCLES 2015 4 A programming language has the built-in function CONCAT defined as follows: CONCAT(String1 : STRING, String2 : STRING [, String3 : STRING] ) RETURNS STRING For example: CONCAT("San", "Francisco") returns "SanFrancisco" CONCAT("New", "York", "City") returns "NewYorkCity" The use of the square brackets indicates that the parameter is optional. (a) State the value returned by the following expressions. If the expression is not properly formed, write ERROR. (i) CONCAT("Studio", 54) … [1] (ii) CONCAT("parity", "error", "check") … [1] (iii) CONCAT(CONCAT("Binary", "▼", "Coded"), "▼", "Decimal") ▼ indicates a <Space> character …[2] (b) A country has a number of banks. There are cash dispensers all over the country. Each bank is responsible for a number of dispensers. • banks have a three digit code in the range 001 – 999 • each dispenser has a five digit code in the range 00001 – 99999 A text file, DISPENSERS, is to be created. It has one line of text for each dispenser. For example: 00342▼007. This line in the file is the data for dispenser 00342 which belongs to bank 007. Incomplete pseudocode follows for the creation of the file DISPENSERS.
Question paper, page 9
9 9608/23/M/J/15 © UCLES 2015 [Turn over For the creation of the file, data is entered by the user at the keyboard. (i) Complete the pseudocode. OPENFILE … FOR WRITE … OUTPUT "Enter dispenser code (XXXXX to end)" INPUT DispenserCode IF DispenserCode <> "XXXXX" THEN OUTPUT "Enter bank code" INPUT BankCode LineString CONCAT(… , "▼", BankCode) // now write the new line to the file … ENDIF UNTIL … … OUTPUT "DISPENSERS file now created" [6] (ii) No attempt has been made to validate the data entered by the user. Describe two different types of validation check for the data entry. 1 … … 2 … …[2] (iii) The programmer coded this algorithm above and the user successfully entered 15 dispenser records into the text file. There is data for another 546 dispensers which needs to be added. State the error that will occur if the user runs the program a second time for further data entry. …[1] (iv) Give the ‘file mode’ available in the programming language which will be used to address this issue. …[1]
Question paper, page 10
10 9608/23/M/J/15 © UCLES 2015 (c) The complete data file is created with the structure shown. A new program is to be written to search the file. The program will: • input a bank code • output a list of all the dispensers which belong to this bank • output the total number of dispensers for this bank 00001▼007 00002▼001 00003▼002 00004▼003 00005▼101 00006▼004 00007▼004 00024▼002 00025▼003 00026▼007 00027▼007 00028▼102 99867▼013 An example of a run of the program is shown: Enter bank code 007 00001 00011 00022 00026 00027 There are 5 dispensers for this bank
Question paper, page 11
11 9608/23/M/J/15 © UCLES 2015 [Turn over Write the program code. Do not attempt to include any validation checks. 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 12
12 9608/23/M/J/15 © UCLES 2015 5 A firm employs workers who assemble amplifiers. Each member of staff works an agreed number of hours each day. The firm records the number of completed amplifiers made by each employee each day. Management monitor the performance of all its workers. Production data was collected for 3 workers over 4 days. Daily hours worked Production data Worker 1 5 Worker 1 Worker 2 Worker 3 Worker 2 10 Day 1 10 20 9 Worker 3 10 Day 2 11 16 11 Day 3 10 24 13 Day 4 14 20 17 A program is to be written to process the production data. (a) The production data is to be stored in a 2-dimensional array ProductionData, declared as follows: DECLARE ProductionData ARRAY[1:4, 1:3] : INTEGER (i) Describe two features of an array. 1 … … 2 … …[2] (ii) Give the value of ProductionData[3, 2]. …[1] (iii) Describe the information produced by the expression: ProductionData[2, 1] + ProductionData[2, 2] + ProductionData[2, 3] … …[2]
Question paper, page 13
13 9608/23/M/J/15 © UCLES 2015 [Turn over (b) Complete the trace table for the pseudocode algorithm below. FOR WorkerNum 1 TO 3 WorkerTotal[WorkerNum] 0 ENDFOR FOR WorkerNum 1 TO 3 FOR DayNum 1 TO 4 WorkerTotal[WorkerNum] WorkerTotal[WorkerNum] + ProductionData[DayNum, WorkerNum] ENDFOR ENDFOR FOR WorkerNum 1 TO 3 WorkerAverage WorkerTotal[WorkerNum]/ (4 * DailyHoursWorked[WorkerNum]) IF WorkerAverage < 2 THEN OUTPUT “Investigate“, WorkerNum ENDIF ENDFOR WorkerTotal WorkerNum DayNum WorkerAverage OUTPUT 1 2 3 [8]
Question paper, page 14
14 9608/23/M/J/15 © UCLES 2015 (c) An experienced programmer suggests that the pseudocode would be best implemented as a procedure AnalyseProductionData. Assume that both arrays, DailyHoursWorked and ProductionData, are available to the procedure from the main program and they are of the appropriate size. PROCEDURE AnalyseProductionData(NumDays : INTEGER, NumWorkers : INTEGER) DECLARE … DECLARE … DECLARE … DECLARE … FOR WorkerNum 1 TO 3 WorkerTotal[WorkerNum] 0 ENDFOR FOR WorkerNum 1 TO 3 FOR DayNum 1 TO 4 WorkerTotal[WorkerNum] WorkerTotal[WorkerNum] + ProductionData[DayNum, WorkerNum] ENDFOR ENDFOR FOR WorkerNum 1 TO 3 WorkerAverage WorkerTotal[WorkerNum]/ (4 * DailyHoursWorked [WorkerNum]) IF WorkerAverage < 2 THEN OUTPUT "Investigate", WorkerNum ENDIF ENDFOR ENDPROCEDURE (i) Complete the declaration statements showing the local variables. [4] (ii) The original pseudocode has been ‘pasted’ under the procedure header. Circle all the places in the original pseudocode where changes will need to be made. Write the changes which need to be made next to each circle. [3] (iii) Write the statement for a procedure call which processes data for 7 days for 13 workers. …[1]
Question paper, page 15
15 9608/23/M/J/15 © UCLES 2015 BLANK PAGE
Question paper, page 16
16 9608/23/M/J/15 © UCLES 2015 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 the registered trademark of Cambridge International Examinations. CAMBRIDGE INTERNATIONAL EXAMINATIONS Cambridge International Advanced Subsidiary and Advanced Level MARK SCHEME for the May/June 2015 series 9608 COMPUTER SCIENCE 9608/23 Paper 2 (Written Paper), maximum raw mark 75 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 2015 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 2015 9608 23 © Cambridge International Examinations 2015 1 (a) Identifier Data Type Description HorseName STRING Name of the horse NumberOfPreviousWins INTEGER Number of previous wins RacePenaltyWeight INTEGER / REAL / SINGLE Penalty weight [1] (b) (i) Stepwise refinement // top-down design [1] (ii) INPUT HorseName INPUT NumberOfPreviousWins RacePenaltyWeight 0 IF NumberOfPreviousWins = 1 OR NumberOfPreviousWins = 2 THEN RacePenaltyWeight 4 ENDIF IF NumberOfPreviousWins > 2 THEN RacePenaltyWeight 8 ENDIF OUTPUT HorseName, RacePenaltyWeight Mark as follows: (OUTPUT ) + INPUT x 2 (1 mark) Two/three conditions in evidence correctly formed (1 mark) (penalise Assignment used for equals) Condition for penalty weight = 0 + assignment = 0 (1 mark) Other conditions X 2 + Assignment of 4 and 8 (1 mark) Final output of horse name + penalty weight (1 mark) [5] 2 (a) (i) 7 [1] (ii) 2 9 [2]
Mark scheme, page 3
Page 3 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2015 9608 23 © Cambridge International Examinations 2015 (b) (i) Input value Output Comment Amount Fifty Dollar Twenty Dollar Ten Dollar 70 1 1 0 Least possible number of notes 85 ( 0 0 0 ) Error message 130 2 1 1 Least possible number of notes 600 ( 0 0 0 ) Error message Penalise any number entries on the 85 and 600 rows [3] (ii) INPUT Amount IF Amount > 500 THEN OUTPUT "Refused – amount too large" ELSE IF (Amount MOD 10) <> 0 / >0 THEN OUTPUT "Refused - not a multiple of $10" ELSE FiftyDollar ← Amount DIV 50 Temp ← Amount MOD 50 // (Amount – 50 * FiftyDollar) TwentyDollar ← Temp DIV 20 // (Amount MOD 50) DIV 20 Temp ← Temp MOD 20 TenDollar ← Temp DIV 10 ENDIF ENDIF [max 5] 3 (i) A Width in any order B Length C JobID D CustomerName in any order E JobCost [5]
Mark scheme, page 4
Page 4 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2015 9608 23 © Cambridge International Examinations 2015 (ii) PROCEDURE CalculateJobCost (BYREF JobCost : INTEGER/CURRENCY/REAL, BYVALUE Length : INTEGER, BYVALUE Width : INTEGER) mark as follows: identifier + data type × 3 (3 marks) jobcost (only) BYREF (1 mark) length, width (only) BYVALUE/BYREF (1 mark) [5] 4 (a) (i) ERROR [1] (ii) parityerrorcheck [1] (iii) Binary Coded Decimal // BinaryCodedDecimal [2] (b) (i) OPENFILE "DISPENSERS" FOR WRITE (1 mark) REPEAT (1 mark) OUTPUT "Enter dispenser code (XXXXX to end)" INPUT DispenserCode IF DispenserCode <> "XXXXX" THEN OUTPUT "Enter bank code …" INPUT BankCode LineString ← CONCAT(DispenserCode, "",BankCode) (1 mark) // now write the new line to the file WRITEFILE ("DISPENSERS"), LineString (1 mark) ENDIF UNTIL DispenserCode = "XXXXX" (1 mark) CLOSE ("DISPENSERS") // CLOSEFILE (1 mark) OUTPUT "DISPENSERS file now created" [6] (ii) • Bank code/ Dispenser code is digit characters only • Bank code is exactly 3 digits // Dispenser code is exactly 5 digits • Range check on Bank code between 1 and 999 // range check on dispenser code between 1 and 99999 Note: If no reference made to either Bank code or Dispenser code MAX 1 [max 2] (iii) data of the existing 15 dispensers will be lost/overwritten [1] (iv) Append // Illustrated with program code statement [1]
Mark scheme, page 5
Page 5 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2015 9608 23 © Cambridge International Examinations 2015 (c) Mark as follows: • Variables declared/commented (at least X2) (1 mark) • Input of ‘ThisBank’ with prompt (1 mark) • File open statement (1 mark) • File mode is ‘Input’ (1 mark) • File close • Loop (Not a FOR loop) (1 mark) • Until all records considered • Isolate LineBankCode (1 mark) • Isolate LineDispenserCode • Count initialised (1 mark) • Count incremented (1 mark) • Output – List of dispenser codes (1 mark) • Output – dispenser count (1 mark) [max 10] Visual Basic … Dim DispenserRecord As String Dim DispenserCode As String : Dim Bank As String Dim DispenserCount As Integer Dim ThisBank As String FileOpen(1, "C:\DISPENSERS.txt", OpenMode.Input) Console.WriteLine() Console.Write("Which bank ..(Three digit code)? ") ThisBank = Console.ReadLine DispenserCount = 0 Do DispenserRecord = LineInput(1) DispenserCode = Left(DispenserRecord, 5) Bank = Mid(DispenserRecord, 7, 3) If Bank = ThisBank Then DispenserCount = DispenserCount + 1 Console.WriteLine(DispenserCode) End If Loop Until EOF(1) FileClose(1) Console.WriteLine() Console.WriteLine("There are " & DispenserCount & " dispensers for this bank")
Mark scheme, page 6
Page 6 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2015 9608 23 © Cambridge International Examinations 2015 Python … # DispenserLine – String # DispenserCode - String # Bank - String # DispenserCount - Integer # ThisBank - String MyFile = open("c:\DISPENSERS.txt", "r") ThisBank = input("Which bank ..(Three digit code)? ") DispenserCount = 0 while 1: DispenserLine = MyFile.readline() if not DispenserLine: break DispenserCode = DispenserLine[0:5] # slices chars 0,1,2,3,4 Bank = DispenserLine[6:9] # slices chars 6,7,8 if Bank == ThisBank: DispenserCount = DispenserCount + 1 print(DispenserCode) MyFile.close() print print("There are " + str(DispenserCount) " dispensers for this bank") Pascal … var DispenserRecord : String ; var DispenserCode : String ; var Bank : String ; var DispenserCount : Integer ; var ThisBank : String ; var TheFile : Text ; begin assign(TheFile, 'K:\DISPENSERS.txt') ; reset(TheFile) ; WriteLn() ; Write('Which bank ..(Three digit code)? ') ; Readln(ThisBank) ; C DispenserCount := 0 ; repeat readln(TheFile, DispenserRecord) ; DispenserCode := Copy(DispenserRecord,1, 5) ; Bank := copy(DispenserRecord, 7, 3) ; If Bank = ThisBank Then begin DispenserCount := DispenserCount + 1 ;
Mark scheme, page 7
Page 7 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2015 9608 23 © Cambridge International Examinations 2015 Writeln(DispenserCode) end ; until EOF(TheFile) ; close(TheFile) ; writeLn() ; writeLn('Dispenser count: ', DispenserCount) ; readln ; end. 5 (a) (i) • Set of data items have a common name (1 mark) • Items are referenced using a subscript/index (1 mark) • Accept: all data items are of the same data type (1 mark) [max 2] (ii) 24 [1] (iii) • The total number of amplifiers ‘produced’ by workers 1, 2 and 3/three workers (1 mark) • on day 2 (1 mark) [2]
Mark scheme, page 8
Page 8 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2015 9608 23 © Cambridge International Examinations 2015 (b) WorkerTotal WorkerNum DayNum WorkerAverage OUTPUT 1 2 3 1 0 2 0 3 0 1 1 10 2 21 3 31 4 45 2 1 20 2 36 3 60 4 80 3 1 9 2 20 3 33 4 50 1 2.25 2 2 3 1.25 INVESTIGATE 3 [8]
Mark scheme, page 9
Page 9 Mark Scheme Syllabus Paper Cambridge International AS/A Level – May/June 2015 9608 23 © Cambridge International Examinations 2015 (c) (i) WorkerNum : INTEGER (1 mark) DayNum : INTEGER (1 mark) WorkerTotal : ARRAY OF INTEGER (1 mark) (1 mark) WorkerAverage : REAL (1 mark) [max 4] (ii) PROCEDURE AnalyseProductionData(NumDays : INTEGER, NumWorkers : INTEGER) FOR WorkerNum ← 1 TO 3 WorkerTotal [WorkerNum] ← 0 ENDFOR FOR WorkerNum ← 1 TO 3 FOR DayNum ← 1 TO 4 WorkerTotal[WorkerNum] ← WorkerTotal[WorkerNum] + ProductionData[WorkerNum, DayNum] ENDFOR ENDFOR FOR WorkerNum ← 1 TO 3 WorkerAverage = WorkerTotal[WorkerNum] / (4 * DailyHoursWorked[WorkerNum] IF WorkerAverage < 2 THEN OUTPUT "Investigate" WorkerNum ENDIF ENDFOR ENDPROCEDURE Mark as follows: All ‘3’s changed to NumWorkers All ‘4’s changed to NumDays WorkerAverage ‘4’ changed to NumDays [3] (iii) (CALL) AnalyseProductionData(7, 13) [1]
What you needed in this session
Cambridge’s own grade thresholds for 2015 May/June, Paper 2 · Variant 3. A higher threshold means an easier paper — the bar moves with how the cohort did.