Cambridge A Level Computer Science 9608 — 2020 May/June Paper 2 · Variant 3
9608/23/M/J/20
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 paper20 pages




















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
















Paper as text
Question paper, page 1
This document has 20 pages. Blank pages are indicated. DC (RW/TP) 180778/4 © UCLES 2020 [Turn over * 1 7 5 3 4 1 4 9 7 5 * COMPUTER SCIENCE 9608/23 Paper 2 Fundamental Problem-solving and Programming Skills May/June 2020 2 hours You must answer on the question paper. No additional materials are needed. INSTRUCTIONS ● Answer all questions. ● Use a black or dark blue pen. ● Write your name, centre number and candidate number in the boxes at the top of the page. ● Write your answer to each question in the space provided. ● Do not use an erasable pen or correction fluid. ● Do not write on any bar codes. ● You may use an HB pencil for any diagrams, graphs or rough working. ● Calculators must not be used in this paper. INFORMATION ● The total mark for this paper is 75. ● The number of marks for each question or part question is shown in brackets [ ]. ● No marks will be awarded for using brand names of software packages or hardware. Cambridge International AS & A Level
Question paper, page 2
2 9608/23/M/J/20 © UCLES 2020 BLANK PAGE
Question paper, page 3
3 9608/23/M/J/20 © UCLES 2020 [Turn over 1 (a) Algorithms are produced during program development. State when you would produce an algorithm during program development and state its purpose. When … … Purpose … … [2] (b) Selection is one of the basic constructs used in algorithms. Explain the term selection. … … … … [2] (c) Explain the process of problem decomposition. State one reason it may be used. Explanation … … … Reason … … … [2] (d) Name two features provided by a typical Integrated Development Environment (IDE) that assist in the debugging stage of the program development cycle. 1 … 2 … [2]
Question paper, page 4
4 9608/23/M/J/20 © UCLES 2020 2 (a) A structure chart is often produced as part of a modular program design. The chart shows the relationship between modules and the parameters that are passed between them. Give two other features the structure chart can show. Feature 1 … … Feature 2 … … [2] (b) The following structure chart shows the relationship between three modules. ModuleA() ModuleB() ParX ParZ ParW ModuleC() Parameter data types are: ParW : REAL ParX : INTEGER ParZ : STRING (i) Write the pseudocode header for module ModuleB(). … … … [3] (ii) Write the pseudocode header for module ModuleC(). … … … [3]
Question paper, page 5
5 9608/23/M/J/20 © UCLES 2020 [Turn over (c) A student is developing an algorithm to count the number of times a given string, SearchString, appears in a 2D array. The array, Item, consists of 100 elements organised as 50 rows of 2 columns. SearchString could appear in any row or column. The array is declared in pseudocode as follows: DECLARE Item : ARRAY [1:50, 1:2] OF STRING The structured English description of the algorithm is: 1. SET Count to 0. 2. Examine the first row of the array. 3. IF column 1 element value is equal to SearchString, ADD 1 to Count. 4. IF column 2 element value is equal to SearchString, ADD 1 to Count. 5. REPEAT from step 3 for next row, UNTIL row is last row. 6. OUTPUT a suitable message and Count. Write pseudocode for the algorithm. … … … … … … … … … … … … … … … [5]
Question paper, page 6
6 9608/23/M/J/20 © UCLES 2020 BLANK PAGE
Question paper, page 7
7 9608/23/M/J/20 © UCLES 2020 [Turn over 3 (a) Study the following pseudocode. Error Delta(Plan, Actual) CASE OF Error > 10 : Steer Steer − 10 0 : ZCount ZCount + 1 < -10 : Steer Steer + 10 OTHERWISE OUTPUT "Unexpected Error" ENDCASE Draw a program flowchart to represent the pseudocode. Variable declarations are not required in program flowcharts. [5]
Question paper, page 8
8 9608/23/M/J/20 © UCLES 2020 (b) The following pseudocode algorithm has been developed to check whether a string contains a valid password. To be a valid password, a string must: • be longer than five characters • contain at least one numeric digit • contain at least one upper case letter • contain at least one other character (not a numeric digit or an upper case letter). 10 FUNCTION Check(InString : STRING) RETURNS BOOLEAN 11 12 DECLARE Index : INTEGER 13 DECLARE StrLen : INTEGER 14 DECLARE NumUpper, NumDigit : INTEGER 15 DECLARE NextChar : CHAR 16 DECLARE NumOther : INTEGER 17 18 NumUpper 0 19 NumDigit 0 20 21 StrLen LENGTH(InString) 22 IF StrLen < 6 23 THEN 24 RETURN FALSE 25 ELSE 26 FOR Index 1 TO StrLen - 1 27 // loop for each character 28 NextChar MID(InString, Index, 1) 29 IF NextChar >= '0' AND NextChar <= '9' 30 THEN 31 NumDigit NumDigit + 1 // count digits 32 ELSE 33 IF NextChar >= 'A' AND NextChar <= 'Z' 34 THEN 35 NumUpper NumUpper + 1 // count upper case 36 ENDIF 37 ENDIF 38 ENDFOR 39 ENDIF 40 41 NumOther StrLen – (NumDigit – NumUpper) 42 IF NumDigit >= 1 AND NumUpper >= 1 AND NumOther >= 1 43 THEN 44 RETURN TRUE 45 ELSE 46 RETURN FALSE 47 ENDIF 48 49 ENDFUNCTION
Question paper, page 9
9 9608/23/M/J/20 © UCLES 2020 [Turn over The pseudocode does not work under all circumstances. The function was dry run with the string "1234AP" and the following trace table was produced. The string is an invalid password, but the pseudocode returned the value TRUE. Trace table row StrLen Index NextChar NumUpper NumDigit NumOther 1 6 0 0 2 1 '1' 3 1 4 2 '2' 5 2 6 3 '3' 7 3 8 4 '4' 9 4 10 5 'A' 11 1 12 3 (i) The pseudocode algorithm contains two errors. State how the given trace table indicates the existence of each error. Error 1 … … … … Error 2 … … … … [2]
Question paper, page 10
10 9608/23/M/J/20 © UCLES 2020 (ii) Give the line number of each error in the pseudocode algorithm and write the modified pseudocode to correct each error. Line number for error 1 … Correct pseudocode … … Line number for error 2 … Correct pseudocode … … [2] (c) The term adaptive maintenance refers to amendments that are made in response to changes to the program specification. These changes usually affect the program algorithm. Name one other part of the design that can change as a result of adaptive maintenance. … [1] 4 A global 1D array, Contact, of type STRING is used to store a list of names and email addresses. There are 1000 elements in the array. Each element stores one data item. The format of each data item is as follows: <Name>':'<EmailAddress> Name and EmailAddress are both variable-length strings. For example: "Wan Zhu:zwan99@mymail.com" A function, Extract(), is part of the program that processes the array. A string data item is passed to the function as a parameter. The function will return the Name part. Validation is not necessary.
Question paper, page 11
11 9608/23/M/J/20 © UCLES 2020 [Turn over (a) Write program code for the function Extract(). 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 … … … … … … … … … … … … … … … … … … [5]
Question paper, page 12
12 9608/23/M/J/20 © UCLES 2020 (b) The original function, Extract(), needs to be modified to separate the name from the email address. The calling program can then use both of these values. Write, in pseudocode, the header for the modified subroutine. Explain the changes you have made. Subroutine header … … Explanation … … … … … … [3] 5 A company hires out rowing boats on a lake. The company has 20 boats, numbered from 1 to 20. For safety reasons, the boats have to be serviced (checked and any damage repaired) regularly. The company is developing a program to help manage the servicing of the boats. Every time a boat is serviced, details are added at the end of the text file, ServiceLog.txt, as a single line of information. Each boat is serviced before it is hired out for the first time. The format of each line is as follows: <BoatNumber><Date> BoatNumber and Date are as follows: • BoatNumber is a two-digit numeric string in the range "01" to "20" • Date is an 8-digit numeric string in the format YYYYMMDD The programmer has defined the first module as follows: Module Description GetLastService() • Called with a string parameter representing the BoatNumber • Searches through the file ServiceLog.txt • Returns the date of the last service in the form "YYYYMMDD"
Question paper, page 13
13 9608/23/M/J/20 © UCLES 2020 [Turn over (a) Write pseudocode for the module GetLastService(). Refer to the Appendix on page 19 for a list of built-in pseudocode functions and operators. … … … … … … … … … … … … … … … … … … … … … … … … [8]
Question paper, page 14
14 9608/23/M/J/20 © UCLES 2020 (b) (i) Every time a boat is hired out, details of the hire are added at the end of a text file, Hirelog.txt. Each line of the text file corresponds to information about the hire of one boat. The format of each line of information is as follows: <Date><BoatNumber><HireDuration> • Date is an 8-digit numeric string in the format YYYYMMDD • BoatNumber is a two-digit numeric string in the range "01" to "20" • HireDuration is a variable-length string representing a numeric value in hours. For example, the string "1.5" would represent a hire duration of 1½ hours. A module GetHours() is defined as follows: Module Description GetHours() • Takes two parameters: the BoatNumber as a string the date of the last service for that boat ("YYYYMMDD") as a string • Searches through file Hirelog.txt and calculates the sum of the hire durations for the given boat after the given date (hire durations on or before the given date are ignored) • Returns the total of the hire durations as a real Note: Standard comparison operators may be used with dates in this format. For example: "20200813" > "20200812" would evaluate to TRUE Parameter validation is not required.
Question paper, page 15
15 9608/23/M/J/20 © UCLES 2020 [Turn over Write pseudocode for the module GetHours(). Refer to the Appendix on page 19 for a list of built-in pseudocode functions and operators. … … … … … … … … … … … … … … … … … … … … … … … [8]
Question paper, page 16
16 9608/23/M/J/20 © UCLES 2020 (ii) An additional module, Validate(), has been written to check that a given string corresponds to a valid BoatNumber. A valid BoatNumber is a two-digit numeric string in the range "01" to "20". Give three test strings that are invalid for different reasons. Explain your choice in each case. String 1 … Reason … … … String 2 … Reason … … … String 3 … Reason … … … [6] (c) A new module is described as follows: Module Description ServiceList() • Takes an integer as a parameter that represents the maximum number of hours before a boat must be serviced • Uses GetLastService() and GetHours() • Outputs: a suitable heading the BoatNumber of each boat hired for more than the maximum number of hours since its last service the total hire duration for each of these boats An example output list is: Boat Service List 4: 123 17: 117 If no boats are due to be serviced, the output is: Boat Service List No boats are due to be serviced
Question paper, page 17
17 9608/23/M/J/20 © UCLES 2020 [Turn over Write program code for the module ServiceList(). Python: You should show a comment statement for each variable used with its data type. Visual Basic and Pascal: You should include the declaration statements for variables. Programming language … Program code … … … … … … … … … … … … … … … … … … … … … … … … … [8]
Question paper, page 18
18 9608/23/M/J/20 © UCLES 2020 (d) (i) A team of programmers will work on the program. Before they begin, the team meet to discuss ways in which the risk of program faults may be reduced during the design and coding stages. State two ways to minimise program faults during the design and coding stages. 1 … … 2 … … [2] (ii) During development, the team test the program using a process known as stub testing. Explain this process. … … … … [2] (iii) Explain how single stepping may be used to help find a logic error in a program. … … … … [2]
Question paper, page 19
19 9608/23/M/J/20 © UCLES 2020 Appendix Built-in functions (pseudocode) Each function returns an error if the function call is not properly formed. LENGTH(ThisString : STRING) RETURNS INTEGER returns the integer value representing the length of 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 "ABC" RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING returns rightmost x characters from ThisString Example: RIGHT("ABCDEFGH", 3) returns "FGH" 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 "BCD" INT(x : REAL) RETURNS INTEGER returns the integer part of x Example: INT(27.5415) returns 27 NUM_TO_STRING(x : REAL) RETURNS STRING returns a string representation of a numeric value. Note: This function will also work if x is of type INTEGER Example: NUM_TO_STRING(87.5) returns "87.5" STRING_TO_NUM(x : STRING) RETURNS REAL returns a numeric representation of a string. Note: This function will also work if x is of type CHAR Example: STRING_TO_NUM("23.45") returns 23.45 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 20
20 9608/23/M/J/20 © UCLES 2020 BLANK PAGE 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 Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cambridgeinternational.org after the live examination series. Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.
Mark scheme, page 1
This document consists of 16 printed pages. © UCLES 2020 [Turn over Cambridge International AS & A Level COMPUTER SCIENCE 9608/23 Paper 2 Written Paper May/June 2020 MARK SCHEME Maximum Mark: 75 Published Students did not sit exam papers in the June 2020 series due to the Covid-19 global pandemic. This mark scheme is published to support teachers and students and should be read together with the question paper. It shows the requirements of the exam. The answer column of the mark scheme shows the proposed basis on which Examiners would award marks for this exam. Where appropriate, this column also provides the most likely acceptable alternative responses expected from students. Examiners usually review the mark scheme after they have seen student responses and update the mark scheme if appropriate. In the June series, Examiners were unable to consider the acceptability of alternative responses, as there were no student responses to consider. Mark schemes should usually be read together with the Principal Examiner Report for Teachers. However, because students did not sit exam papers, there is no Principal Examiner Report for Teachers for the June 2020 series. Cambridge International will not enter into discussions about these mark schemes. Cambridge International is publishing the mark schemes for the June 2020 series for most Cambridge IGCSE™ and Cambridge International A & AS Level components, and some Cambridge O Level components.
Mark scheme, page 2
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 2 of 16 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 2020 © UCLES 2020 Page 3 of 16 Question Answer Marks 1(a) When: when designing a solution to a problem Purpose: to describe the solution as a sequence of steps / actions One mark per answer Accept equivalent phrase for 'purpose' but reject specific programming references 2 1(b) Testing a condition to determine the sequence of execution One mark per underlined phrase (or equivalent) 2 1(c) Explanation: Breaking a problem down into sub tasks Reason: Make the problem easier to solve // to make the solution easier to implement / test / maintain 2 1(d) • Breakpoints • Single-stepping • Watch window Max 2 2 Question Answer Marks 2(a) • Sequence of (module) execution • Module Iteration • Module selection One mark per item Max 2 2 2(b)(i) FUNCTION ModuleB (ParX : INTEGER) RETURNS BOOLEAN One mark for each underlined part Ignore BYVALUE for ParX 3 2(b)(ii) PROCEDURE ModuleC (BYREF ParW: REAL, BYVALUE ParZ : STRING) One mark for each underlined part BYVALUE not essential for ParZ 3
Mark scheme, page 4
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 4 of 16 Question Answer Marks 2(c) DECLARE Index, Count : INTEGER Count ← 0 FOR Index ← 1 TO 50 IF Item[Index, 1] = SearchString THEN Count ← Count + 1 ENDIF IF Item[Index, 2] = SearchString THEN Count ← Count + 1 ENDIF ENDFOR OUTPUT "The number of times SearchString found: ", Count Alternative DECLARE I, J, Count : INTEGER Count ← 0 FOR I ← 1 TO 50 FOR J ← 1 TO 2 IF Item[I, J] = SearchString THEN Count ← Count + 1 ENDIF ENDFOR ENDFOR OUTPUT "The number of times SearchString found: ", Count One mark for each of the following: 1 Initialisation of Count 2 FOR loop 3 Check column 1 element and increment count 4 Check column 2 element and increment count // nested loops 5 OUTPUT Count together with suitable mesage 5
Mark scheme, page 5
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 5 of 16 Question Answer Marks 3(a) Mark as follows: • One mark for START and END • One mark per area outlined All outputs from CASE must be labelled 5 3(b)(i) Error 1 • Index stops at 5 – shoud go to 6. Fails to loop correctly through all characters of string (lines 26 to 38) // Final values for NumUpper is not as expected (because of loop error) Error 2 • Trace table row 12 – NumOther assigned wrong value. 0 expected not 3 One mark per bullet 2
Mark scheme, page 6
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 6 of 16 Question Answer Marks 3(b)(ii) Error 1 Line Number: 26 Correction: FOR Index ← 1 to StrLen Error 2 Line Number: 41 Correction: NumOther ← StrLen –(NumDigit + NumUpper) One mark for each line number with correction 2 3(c) Data Structure 1
Mark scheme, page 7
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 7 of 16 Question Answer Marks 4(a) 'Pseudocode' solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. FUNCTION Extract(InString : STRING) RETURNS STRING DECLARE Name : STRING DECLARE NextChar : CHAR DECLARE Index : INTEGER CONSTANT COLON = ':' Index ← 1 Name ← "" NextChar ← LEFT(InString, 1) WHILE NextChar <> COLON Name ← Name & NextChar Index ← Index + 1 NextChar ← MID(InString, Index, 1) ENDWHILE RETURN Name ENDFUNCTION Alternative: FUNCTION Extract(InString : STRING) RETURNS STRING DECLARE Name : STRING DECLARE Index : INTEGER CONSTANT COLON = ':' Index ← 1 WHILE MID(InString, Index, 1)<> COLON Index ← Index + 1 ENDWHILE Name ← LEFT(InString, Index) RETURN Name ENDFUNCTION Mark as follows: 1 Function heading and ending (where required) including parameters 2 Extract (next) character from InString 3 Conditional loop while character is not colon 4 Append character to Name and increment Index in a loop // calculate substring length and use LEFT() after loop 5 RETURN Name (may be combined with alternative mp 4) 5
Mark scheme, page 8
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 8 of 16 Question Answer Marks 4(b) Two alternatives: Alternative #1 Header: PROCEDURE Extract (BYREF Name : STRING, BYREF Email : STRING, BYVALUE DataItem : STRING) Explanation: Could additionally pass the name and email address to the procedure using BYREF. Procedure would extract name and email and assign values to BYREF parameters; these would then be available to calling program. Alternative #2 Header: PROCEDURE Extract (DataItem : STRING) Explanation: Declare new global variables for the name and email address. These could be assigned values within the new procedure and these values would be used by the calling program. Mark as follows: • Two marks for header – must be a Procedure not a Function (but see note below) • Max Two marks for explanation Note: Allow solution based on user-defined record type / record item returned from modified function. Max 3 3
Mark scheme, page 9
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 9 of 16 Question Answer Marks 5(a) FUNCTION GetLastService(BoatNum : STRING) RETURNS STRING DECLARE LastService, FileData : STRING LastService ← "" OPEN "ServiceLog.txt" FOR READ WHILE NOT EOF("ServiceLog.txt") READFILE "ServiceLog.txt", FileData IF LEFT(FileData, 2) = BoatNum THEN LastService ← RIGHT(FileData, 8) ENDIF ENDWHILE Close "ServiceLog.txt" RETURN LastService // Most recent service will be the last one read ENDFUNCTION 1 mark for each of the following: 1 Function heading and ending including parameters 2 Declaration of variables for LastService and FileData 3 Open file in read mode and close 4 Conditional loop - while not EOF() 5 Read line from file in a loop 6 Compare BoatNum with data from file in a loop 7 If matched, assign value to LastService in a loop 8 Return LastService 8
Mark scheme, page 10
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 10 of 16 Question Answer Marks 5(b)(i) FUNCTION GetHours(BNum, SDate, : STRING)RETURNS REAL DECLARE FileData, HString : STRING DECLARE TotHours : REAL DECLARE HLength : INTEGER TotHours ← 0 OPEN "HireLog.txt" FOR READ WHILE NOT EOF("HireLog.txt") READFILE "HireLog.txt" FileData IF MID(FileData, 9, 2) = BNum THEN IF LEFT(FileData, 8) > SDate THEN HLength ← LENGTH(Filedata) – 10 HString ← RIGHT(Filedata, HLength) TotHours ← TotHours + STRING_TO_NUM(HString) ENDIF ENDIF ENDWHILE Close "HireLog.txt" RETURN TotHours ENDFUNCTION 1 mark for each of the following: 1 Function heading and ending including parameters 2 Declaration of TotHours as integer 3 ...and initialisation to zero 4 Extract and compare BoatNum … 5 … extract date and compare to ServData and if later then... 6 ... extract HireDuration and … 7 … convert HireDuration to REAL and sum TotHours 8 Return TotHours 8
Mark scheme, page 11
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 11 of 16 Question Answer Marks 5(b)(ii) Three different tests String example 1 • String: "007" • Reason: Too many characters String example 2 • String: "4x" • Reason: String does not represent a numeric value / contains an illegal character String example 3 • String: "25" • Reason: number outside range 1 to 20 Illegal character can only be used in one test One mark for string plus one for corresponding explanation 6
Mark scheme, page 12
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 12 of 16 Question Answer Marks 5(c) 'Pseudocode' solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. PROCEDURE ServiceList(MaxHours : INTEGER) DECLARE BoatNum, Hours : INTEGER DECLARE LastService : STRING DECLARE Due : BOOLEAN Due ← FALSE OUTPUT "Boat Service List" FOR BoatNum ← 1 TO 20 LastService ← GetLastService(NUM_TO_STRING(BoatNum)) Hours ← GetHours(NUM_TO_STRING(BoatNum),LastService) IF Hours > MaxHours THEN OUTPUT NUM_TO_STRING(Boatnum) & ": "__ & NUM_TO_STRING(Hours) Due ← TRUE ENDIF ENDFOR IF Due = TRUE THEN OUTPUT "No boats are due to be serviced" ENDIF ENDPROCEDURE One mark for each of the following: 1 Procedure heading and ending (where appropriate) including parameter 2 Output "report header" line not in a loop 3 Loop from 1 to 20 4 Call GetLastService 5 Call GetHours 6 Check return value from GetHours > MaxHours 7 Suitable Output statement in a loop 8 Mechanism to initialise, count and produce final output if no boats to be serviced 8 5(d)(i) One mark per bullet point • The use of tried and tested (library) subroutines • The use of modular programming (to break the problem down and make it easier to solve) • The use of programming practice to make the code easier to read (e.g. format, use of sensible variable names) Max 2 2
Mark scheme, page 13
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 13 of 16 Question Answer Marks 5(d)(ii) One mark per bullet point • Testing may be carried out before the modules are developed // not ready for full testing • Module stubs contain simple code to provide a known response // temporary replacement for a called module / return a fixed value / output a message to confirm the module has been called 2 5(d)(iii) One mark per bullet point • Executes a line of code at a time • Used to trace the path of execution (sequence) • Track variable values using a watch window Max 2 2
Mark scheme, page 14
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 14 of 16 Program Code Example Solutions Q4(a): Visual Basic Function Extract(InString As String) As String Dim Name As String Dim NextChar As Char Dim Index As Integer Const COLON = ':' Index = 1 Name = "" NextChar = Left(InString, 1) While NextChar <> COLON Name = Name & NextChar Index = Index + 1 NextChar = Mid(Instring, Index, 1) Loop Return Name End Function Function Extract(InString As String) As String Return Mid(Instring, 1, Instring.IndexOf(":")) End Function Q4(a): Pascal function extract(InString : string) : string; var Name : string; NextChar : char; Index : integer; const COLON = ':'; Index := 1; Name := ""; NextChar := copy(InString, 1, 1); While NextChar <> COLON do begin Name := Name & NextChar; Index := Index + 1; NextChar := copy(Instring, Index, 1); end; extract := Name; end;
Mark scheme, page 15
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 15 of 16 Q4(a): Python def Extract(InString) # Name : String # NextChar : Char # Index : Integer COLON = ':' Index = 1 Name = "" NextChar = InString[1:2] While NextChar <> COLON: Name = Name + NextChar Index = Index + 1 NextChar = Instring[index, Index + 1] Return Name Q5(c): Visual Basic Sub ServiceList(MaxHours As Integer) Dim BoatNum, Due As Integer Dim LastService As String Due = 0 console.writeline("Boat Service List") For BoatNum = 1 To 20 LastService = GetLastService(CStr(BoatNum)) Hours = GetHours(CStr(BoatNum), LastService) If Hours > MaxHours Then Console.Writeline(CStr(Boatnum) & ": " & CStr(Hours)) Due = Due + 1 End If Next If Due = 0 Then Console.Writeline("No boats are due to be serviced") End If End Sub
Mark scheme, page 16
9608/23 Cambridge International AS & A Level – Mark Scheme PUBLISHED May/June 2020 © UCLES 2020 Page 16 of 16 Q5(c): Pascal procedure ServiceList(MaxHours : Integer) var BoatNum, Due : integer; LastService : string; Due := 0 print("Boat Service List") for BoatNum := 1 to 20 do begin LastService := GetLastService(CInt(BoatNum)); Hours := GetHours(BoatNum, Lastservice); If Hours > MaxHours then begin writeln(IntToStr(Boatnum) & ": " & IntToStr(Hours)); Due := Due + 1; end; end; If Due = 0 then writeln ("No boats are due to be serviced") End If End Sub Q5(c): Python def ServiceList(MaxHours) # BoatNum, Due : Integer # LastService : String Due = 0 print("Boat Service List") For BoatNum in range(1, 21): LastService = GetLastService(str(BoatNum)) Hours = GetHours(BoatNum, LastService) if Hours > MaxHours: print(str(Boatnum) & ": " & str(Hours)) Due = Due + 1 if Due == 0: print"No boats are due to be serviced")