Cambridge A Level Computer Science 9608 — 2016 Oct/Nov Paper 2 · Variant 3
9608/23/O/N/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.
Question paper20 pages




















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













Paper as text
Question paper, page 1
This document consists of 20 printed pages. DC (LK/FD) 127385 © UCLES 2016 [Turn over Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level * 2 0 5 4 2 7 5 3 4 1 * COMPUTER SCIENCE 9608/23 Paper 2 Fundamental Problem-solving and Programming Skills October/November 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/O/N/16 © UCLES 2016 There is an Appendix on pages 19 and 20. Some questions will refer you to this information. 1 A programmer wants to write a program to calculate the baggage charge for a passenger’s airline flight. Two types of ticket are available for a flight: • economy class (coded E) • standard class (coded S) Each ticket type has a baggage weight allowance as shown below. The airline makes a charge if the weight exceeds the allowance. Ticket type Baggage allowance (kg) Charge rate per additional kg ($) 'E' 16 3.50 'S' 20 5.75 (a) A program flowchart will document the program. The flowchart will contain the following statements: Statement number Statement 1 Charge 0 2 INPUT BaggageWeight 3 Charge ExcessWeight * ChargeRate 4 Is ExcessWeight > 0 ? 5 INPUT TicketType 6 ExcessWeight BaggageWeight - BaggageAllowance 7 BaggageAllowance 16 8 ChargeRate 3.5 9 OUTPUT Charge 10 ChargeRate 5.75 11 BaggageAllowance 20 12 Is TicketType = 'E' ? Complete the flowchart by putting the appropriate statement number in each flowchart symbol. Statement 5 has been done for you.
Question paper, page 3
3 9608/23/O/N/16 © UCLES 2016 [Turn over Start Stop 5 [6]
Question paper, page 4
4 9608/23/O/N/16 © UCLES 2016 (b) The programmer needs data to test the flowchart. Complete the table of test data below to show five tests. TicketType BaggageWeight Explanation Expected output E 15 … … … … … … … … … … … … … … … [5]
Question paper, page 5
5 9608/23/O/N/16 © UCLES 2016 [Turn over (c) The program design is to be amended. The value input by the user for the ticket type is to be validated. Part of the amended flowchart is shown below. Start INPUT TicketType Is TicketType E or S ? Yes No Loop Write pseudocode to use a pre-condition loop for this validation. … … … … … …[3]
Question paper, page 6
6 9608/23/O/N/16 © UCLES 2016 2 A sensing device sends bit values to a computer along data channels. • Channel 1 transmits a sequence of binary values from a sensor • Channel 2 transmits at regular intervals to indicate whether the sensor is switched on or off: • 0 indicates switched off • 1 indicates switched on A program tests the bits received from the sensing device. A program reads the signal from Channel 2 after every six values from Channel 1. A built-in function READ(<ChannelNumber>) reads a value from the specified channel. Pseudocode for the program is as follows: 01 BitCount 0 02 Status2 READ(2) 03 WHILE Status2 = 1 04 05 FOR ReadingCount 1 TO 6 06 ThisBit READ(1) 07 IF ThisBit = 1 08 THEN 09 BitCount BitCount + 1 10 ENDIF 11 IF BitCount = 5 12 THEN 13 OUTPUT "Error – Investigate" 14 BitCount 0 15 ENDIF 16 ENDFOR 17 18 Status2 READ(2) 19 ENDWHILE
Question paper, page 7
7 9608/23/O/N/16 © UCLES 2016 [Turn over (a) Trace the execution of the program for the following sequence of bits. Channel 1 1 0 1 1 1 0 1 1 0 0 1 1 Channel 2 1 1 0 Status2 ReadingCount ThisBit BitCount OUTPUT 0 1 1 1 1 2 [7] (b) Identify the following constructs in the given program, using line numbers. For multi-line constructs give the first line number only. Construct Line number Assignment Selection Iteration [3]
Question paper, page 8
8 9608/23/O/N/16 © UCLES 2016 3 You will need to refer to the list of pseudocode string-handling functions in the Appendix. ASCII code table (part) Character Decimal Character Decimal Character Decimal <Space> 32 I 73 R 82 A 65 J 74 S 83 B 66 K 75 T 84 C 67 L 76 U 85 D 68 M 77 V 86 E 69 N 78 W 87 F 70 O 79 X 88 G 71 P 80 Y 89 H 72 Q 81 Z 90 (a) For each statement, write the value assigned to the variable. (i) Term CHARACTERCOUNT("TSUNAMI") Term …[1] (ii) Answer1 ASC('G') + ASC(<Space>) Answer1 …[1] (iii) Answer2 CHR(CHARACTERCOUNT("HELLO") + 70) Answer2 …[1] (iv) Word SUBSTR("Welcome home", 4, 7) ) Word …[1]
Question paper, page 9
9 9608/23/O/N/16 © UCLES 2016 [Turn over Question 3(b) continues on page 10.
Question paper, page 10
10 9608/23/O/N/16 © UCLES 2016 (b) A programmer wants to design a procedure to calculate a customer ID number from the customer’s surname. The procedure will: • input the surname • isolate each character in the surname and find the corresponding ASCII code • calculate the total of all these ASCII codes • this total is the customer ID (i) Complete the pseudocode for this procedure. You will need to refer to the list of pseudocode string-handling functions in the Appendix. PROCEDURE CalculateCustomerID OUTPUT "Key in surname" INPUT Surname Length … CustomerID 0 FOR i 1 TO Length // NextChar is a single character from Surname NextChar … NextCodeNumber ASC(NextChar) CustomerID CustomerID + … ENDFOR OUTPUT "Customer ID is ", CustomerID [3]
Question paper, page 11
11 9608/23/O/N/16 © UCLES 2016 [Turn over (ii) Write program code for procedure CalculateCustomerID. Visual Basic and Pascal: You should include declaration statements for variables. Python: You should show a comment statement for each variable used with its data type. Programming language … … … … … … … … … … … … … … … … …[6]
Question paper, page 12
12 9608/23/O/N/16 © UCLES 2016 (c) The programmer decides that it would be better to write the procedure as a function. The user will now input the surname in the main program. Write program code for the following: State your programming language … (i) The function header for this new function CalculateCustomerID …[3] (ii) The additional statement required within the function body to complete the change from a procedure to a function. … …[1] (iii) The statement in the main program which: • calls the function for surname Wilkes • assigns the result to variable ThisID …[3] (d) (i) The new function CalculateUserID is an example of a ‘user-defined function’. State two differences between a built-in function and a user-defined function. 1 … … 2 … …[2] (ii) State two things that built-in and user-defined functions have in common. 1 … … 2 … …[2]
Question paper, page 13
13 9608/23/O/N/16 © UCLES 2016 [Turn over 4 A company employs Ahmed as a programmer. (a) At College, before joining the company, Ahmed used two items of software for programming: • a text editor • a compiler Describe how he could have developed programs using these software tools. Include in the description the terms ‘object code’ and ‘source code’. … … … … … … …[3] (b) Ahmed now uses an Integrated Development Environment (IDE) for programming. (i) State one feature an IDE provides to help with the identification of syntax errors. … …[1] (ii) State one feature an IDE provides to carry out white box testing. … …[1] (c) The company maintains a file of product data. Ahmed is to write a program to add a new product and search for a product based on the structure diagram shown: Product processing Add product Search for product By product code By description By price
Question paper, page 14
14 9608/23/O/N/16 © UCLES 2016 The program records the following data for each product: • product code • product description • product retail price The text file PRODUCTS stores each data item on a separate line, as shown below: File PRODUCTS 0198 Plums(10kg) 11.50 0202 Onions(20kg) 10.00 0376 Mango chutney(1kg) 02.99 0014 Mango(10kg) 12.75 The program uses the variables shown in the identifier table. Identifier Data type Description PRODUCTS TEXT FILE Storing the code, description and retail price for all current products PCode ARRAY[1:1000] OF STRING Array storing the product codes PDescription ARRAY[1:1000] OF STRING Array storing the product descriptions PRetailPrice ARRAY[1:1000] OF REAL Array storing the product retail prices i INTEGER Array index used by all three arrays
Question paper, page 15
15 9608/23/O/N/16 © UCLES 2016 [Turn over (i) The first operation of the program is to read all the product data held in file PRODUCTS and write them into the three 1D arrays. Complete the pseudocode below. OPEN … i 1 WHILE … READFILE ("PRODUCTS", …) READFILE ("PRODUCTS", …) READFILE ("PRODUCTS", …) … … ENDWHILE CLOSE "PRODUCTS" OUTPUT "Product file contents written to arrays" [5] When Ahmed designed the PRODUCTS file, he considered the alternative file structure shown opposite. It stores one product per line in the text file. File PRODUCTS 0198 Plums(10kg) 11.50 0202 Onions(20kg) 10.00 0376 Mango chutney(1kg) 02.99 0014 Mango(10kg) 12.75 (ii) State one benefit and one drawback of this file design. Benefit … … Drawback … …[2]
Question paper, page 16
16 9608/23/O/N/16 © UCLES 2016 (d) To code the ‘Search by product code’ procedure, Ahmed draws a structure chart showing the different stages. The procedure uses the variables shown in the identifier table. Identifier Data type Description SearchCode STRING Product code input by the user ThisIndex INTEGER Array index position for the corresponding product ThisDescription STRING Product description found ThisRetailPrice REAL Product retail price found You can assume that before the procedure is run, all the product data is read from file PRODUCTS and then stored in three 1D arrays as described in part (c)(i). Label the structure chart to show the input(s) and output(s). Lookup by product code INPUT search criteria Search for product code OUTPUT details … … … … … … … [4]
Question paper, page 17
17 9608/23/O/N/16 © UCLES 2016 [Turn over (e) A first attempt was made at writing the ‘Search for product code’ module. Ahmed designs this as a function ProductCodeSearch. The function returns an integer value as follows: • if the product code is found, it returns the index position of the 1D array PCode being searched • if the product code is not found, the function returns -1 Write program code for function ProductCodeSearch. 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 … … … … … … … … … … … … … … … … … … … …[6]
Question paper, page 18
18 9608/23/O/N/16 © UCLES 2016 5 Study the following pseudocode statements. CONST Pi = 3.1 : REAL DECLARE Triangle, Base, Height, Radius, Cone : REAL DECLARE a, b, c, Answer2 : INTEGER DECLARE Answer1 : BOOLEAN Base 2.6 Height 10 Triangle (Base * Height) / 2 Radius 1 Height 2 Cone 2 * Pi * Radius * (Radius + Height) a 13 b 7 c 3 Answer1 NOT((a + b + c) > 28) Total 34 Total Total - 2 Answer2 a + c * c Give the final value assigned to each variable. (i) Triangle … [1] (ii) Cone … [1] (iii) Answer1 … [1] (iv) Total … [1] (v) Answer2 … [1]
Question paper, page 19
19 9608/23/O/N/16 © UCLES 2016 [Turn over Appendix Built-in functions (pseudocode) ONECHAR(ThisString : STRING, Position : INTEGER) RETURNS CHAR returns the single character at position Position (counting from the start of the string with value 1) from the string ThisString. For example: ONECHAR("New York", 5) returns 'Y' CHARACTERCOUNT(ThisString : STRING) RETURNS INTEGER returns the number of characters in ThisString. For example: CHARACTERCOUNT("New York") returns 8 SUBSTR(ThisString : STRING, Value1 : INTEGER, Value2 : INTEGER) RETURNS STRING returns a sub-string from within ThisString. Value1 is the start index position (counting from the left, starting with 1). Value2 is the final index position. For example: SUBSTR("art nouveau", 5, 11) returns "nouveau" TONUM(ThisString : STRING) RETURNS INTEGER or REAL returns the integer or real equivalent of the string ThisString. For example: TONUM("502") returns the integer 502 TONUM("56.36") returns the real number 56.36 ASC(ThisCharacter : CHAR) RETURNS INTEGER returns an integer which is the ASCII character code for the character ThisCharacter. For example: ASC('A') returns integer 65
Question paper, page 20
20 9608/23/O/N/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. CHR(Value : INTEGER) RETURNS CHAR returns the character that ASCII code number Value represents. For example: CHR(65) returns 'A' RND() RETURNS REAL returns a random number in the range 0 to 0.99999 For example: RND() returns 0.67351 INT(ThisNumber : REAL) RETURNS INTEGER returns the integer part of ThisNumber. For example: INT(12.79) returns 12 Errors For any function, if the program calls the function incorrectly, the function returns an error. Concatenation operator & – Concatenates two expressions of STRING or CHAR data type. For example: "South" & " " & "Pole" produces "South Pole" 'B' & "000654" produces "B000654"
Mark scheme, page 1
® IGCSE is the registered trademark of Cambridge International Examinations. This document consists of 13 printed pages. © UCLES 2016 [Turn over Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/23 Paper 2 Written Paper October/November 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 October/November 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 – October/November 2016 9608 23 © UCLES 2016 1 (a) 2 12 7 11 8 10 6 4 1 3 9 Yes Yes No No Note: Order of 11, 10 and 7,8 may be reversed.
Mark scheme, page 3
Page 3 C One • • • • • • • (b) Row Tic E E S S E S E o On Cambridge e mark for e 2 7 and 8 fro 10 and 11 6 1 and 3 (1 9 12 and 4 ws 2 to 7 a ketType or S e mark for e Internatio each of the om YES from NO, 3 are example BaggageW 15 > 16 <= 20 > 20 16 20 negative o numeric each diffe Mark Sc nal AS/A L © following sy 3 from YES es only Weight Ex U al U al U al U al Bo we ty Bo we ty or non- In rent test (e cheme Level – Oct © UCLES 201 ymbols / sy S) xplanation nder the lowance nder the lowance nder the lowance nder the lowance oundary eight for a ype E ticket oundary eight for a ype S ticket nvalid weigh examples a ober/Nove 16 ymbol comb Expec output 0 Charg 0 Charg 0 0 ht Error m above) mber 2016 inations: cted t ge ge message Syllabus 6 9608 s Paper 23 Max [6 Max [5 6] 5]
Mark scheme, page 4
2 Page 4 C (c) INP WHI END One • • • 2 (a) St One 1 must 'follo shown by a have only 1 above. 0 must 'fo shown by have only above. Cambridge PUT Ticke ILE NOT INPUT Ti DWHILE e mark for e WHILE . Correct co INPUT wit from loop tatus2 R 1 1 0 e mark per ow' 6 as arrow. Can 1 or nothing ollow' 6 as y arrow. Can y 1 or nothin e Internatio etType (TicketTy icketType each of: .. ENDWHI ondition in a thin loop plu ReadingCo 1 2 3 4 5 6 1 2 3 4 5 6 area outline n g Mark Sc nal AS/A L © ype = 'E' e ILE a loop us one befo ount T ed cheme Level – Oct © UCLES 201 ) OR (Ti ore loop // a ThisBit 1 0 1 1 1 0 1 1 0 0 1 1 ober/Nove 16 cketType alternative a BitCou 0 1 1 2 3 4 4 5 0 1 1 1 2 3 mber 2016 = 'S') arrangemen unt O E Inv Syllabus 6 9608 nt leading to OUTPUT Error – vestigate s Paper 23 o correct ex [3 [7 xit 3] 7]
Mark scheme, page 5
Page 5 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2016 9608 23 © UCLES 2016 (b) One mark for each of: • Assignment: 01 // 02 // 06 // 09 // 14 // 18 • Selection: 07 // 11 • Iteration: 03 // 05 [3] 3 (a) (i) 7 [1] (ii) 103 [1] (iii) 'K' [1] (iv) "come" [1] (b) (i) PROCEDURE CalculateCustomerID OUTPUT "Key in surname" INPUT Surname Length ← CHARACTERCOUNT(Surname) CustomerID ← 0 FOR i ← 1 TO Length //NextChar is a single character from Surname Nextchar ← 1 SUBSTR(Surname, i, 1) // ONECHAR(Surname, i) NextCodeNumer ← ASC(NextChar) CustomerID ← CustomerID + NextCodeNumber ENDFOR OUTPUT "Customer ID is ", CustomerID ENDPROCEDURE One mark per phrase in bold [3]
Mark scheme, page 6
Page 6 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2016 9608 23 © UCLES 2016 (ii) 'Pseudocode' solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. PROCEDURE CalculateCustomerID DECLARE Surname : STRING DECLARE NextChar : CHAR DECLARE NextCodeNumber, i, CustomerID, SLength : INTEGER OUTPUT "Key in surname" INPUT Surname SLength ← LEN(Surname) CustomerID ← 0 FOR i ← 1 TO SLength //NextChar is a single character from Surname Nextchar ← MID(Surname, i, 1) NextCodeNumber ← ASC(NextChar) CustomerID ← CustomerID + NextCodeNumber ENDFOR OUTPUT "Customer ID is ", CustomerID ENDPROCEDURE Mark as follows: • Declaration of Surname as STRING and NextChar as CHAR and any three INTEGERs • Prompt and Input • Calculation of string length • FOR Loop to process all characters in the string • Assignment to NextChar in a loop • Assignment to NextCodeNumber in a loop • Totalling CustomerID in a loop • Output following a loop [6] (c) (i) Visual Basic Function CalculateCustomerID(ByVal AnyName AS STRING) As Integer Pascal FUNCTION CalculateCustomerID(AnyName : STRING) : INTEGER Python def CalculateCustomerID(AnyName): Mark as follows: • Correct keyword + Function name • Single input parameter of correct type • Return parameter type [3] (ii) Visual Basic Return customerID // CalculateCustomerID = CustomerID Pascal Result := CustomerID // CalculateCustomerID := CustomerID Python Return CustomerID [1]
Mark scheme, page 7
Page 7 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2016 9608 23 © UCLES 2016 (iii) Visual Basic ThisID = CalculateCustomerID ("Wilkes") Pascal ThisID := CalculateCustomerID ('Wilkes') Python ThisID = CalculateCustomerID ("Wilkes") One mark per underlined element [3] (d) (i) • Built-in functions are made available by the programming language / already in the system • Built-in functions are ready made and tested • User-defined functions can be modified // built-in cannot be modified • User defined functions can be designed to meet the user's requirements • User-defined functions can only be used in that program / module [Max 2] (ii) • They have an identifier name • They return a value • They have none, one or more arguments • Both perform a specific task • Both represent re-usable code • Both are 'called' [Max 2] 4 (a) • Create / modify the source code using the text editor • Compiler translates the source code • Compiler produces the object code [Max 3] (b) (i) • Errors in keywords are highlighted // before the compilation process • Provides line-by-line syntax checking as code is typed in • Provides line number of the error • Display of known identifier names • Auto-complete • Colour-coding • Auto-indent • type checking • Subroutine parameter checking [Max 1] (ii) • Set break-points • Single step / step into/over subroutine • Window to watch the changing value of variables [Max 1]
Mark scheme, page 8
Page 8 C (c) (i) (ii) Cambridge OPEN "PR i ← 1 WHILE NO READ READ READ PRet i ← ENDWHILE CLOSE "P OUTPUT " One mark Benefit: • The n • It may • All the group Drawback • The p three • Difficu • More Max one b e Internatio RODUCTS" OT EOF("P FILE ("PR FILE ("PR FILE ("PR ailPrice i + 1 E PRODUCTS" "Product k per bold ph number of fi y use less s e data relate ped togethe k: program will items of da ult to isolate difficult to s benefit and Mark Sc nal AS/A L © FOR READ PRODUCTS" RODUCTS", RODUCTS", RODUCTS", [i] ← TO " file con hrase (three le read ope storage / sp ed to a sing r need to us ata e data items search one drawba cheme Level – Oct © UCLES 201 D ") , PCode[i , PDescri , Temp // ONUM(Temp ntents wr e READFIL erations is re ace in the f gle product se the string s if the form ack ober/Nove 16 i]) iption[i] / PRetail p) ritten to E() counts a educed (by file if strings is read at o g handling f mat is not co mber 2016 ) lPrice[i] arrays" as a single 2/3rds) s are NOT fi nce / in one unctions to nsistent Syllabus 6 9608 ) mark) ixed length e file operat isolate eac s Paper 23 [5 tion / ch of the [2 5] 2]
Mark scheme, page 9
Page 9 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2016 9608 23 © UCLES 2016 (d) One mark per group (one or more names) as follows: A: SearchCode B: SearchCode // ThisIndex C: ThisRetailPrice, ThisDescription D: SearchCode, ThisDescription, ThisRetailPrice [4] A B C D
Mark scheme, page 10
Page 10 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2016 9608 23 © UCLES 2016 (e) 'Pseudocode' solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. FUNCTION ProductCodeSearch(AnyName : String) RETURNS : Integer DECLARE FoundPos : Integer DECLARE i : Integer i ← 1 FoundPos ← -1 REPEAT IF AnyName = PCode[i] THEN FoundPos ← i ELSE i ← i + 1 ENDIF UNTIL (i = 1001) OR (FoundPos <> -1) RETURN FoundPos ENDFUNCTION Mark as follows: • Function header returns INTEGER • Initialisation of index variable • Loop through array PCode (including exit when found) • Comparison of AnyName with PCode[i] in a loop • Increment index variable in a loop • Return index if AnyName found AND return -1 if AnyName not found [Max 6] 5 (i) 13 / 13.0 [1] (ii) 18.6 [1] (iii) TRUE [1] (iv) 32 [1] (v) 22 [1] *** End of Mark Scheme – Example program code solutions follow ***
Mark scheme, page 11
Page 11 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2016 9608 23 © UCLES 2016 Appendix – Example program code solutions 3(b)(ii): Visual Basic Dim Surname As String Dim NextChar As Char Dim NextCodeNumber As Integer Dim i As Integer Dim CustomerID As Integer Dim SLength As Integer Console.Write("Key in surname ") Surname = Console.ReadLine SLength = Len(Surname) CustomerID = 0 For i = 1 To SLength \\ NextChar is a single character from surname NextChar = Mid(Surname, i, 1) NextCodeNumber = Asc(NextChar) CustomerID = CustomerID + NextCodeNumber Next Console.WriteLine("Customer ID is " & CustomerID) 3(b)(ii): Pascal Var Surname : string; SLength, i, CustomerID, NextCodeNumber : integer; NextChar : char; begin Writeln ('Enter the surname: '); Readln (Surname); SLength := Length(Surname); CustomerID := 0; For i := 1 to SLength do begin NextChar := SurName[i]; NextCodeNumber := Ord(NextChar); CustomerID := CustomerID + NextCodeNumber; end; Writeln ('Customer ID is ', CustomerID); Readln; end.
Mark scheme, page 12
Page 12 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2016 9608 23 © UCLES 2016 3(b)(ii): Python # Surname String # NextChar Char # NextCodeNumber, I, CustomerID, SLength Integer Surname = input("Key in Surname ") SLength = len(Surname) CustomerID = 0 for i in range(SLength): # NextChar is a single character from surname NextChar = Surname[i] NextCodeNumber = ord(NextChar) CustomerID = CustomerID + NextCodeNumber print("Customer ID is " + str(CustomerID)) 4(e): Visual Basic Function ProductCodeSearch(ByVal SearchCode As String) As Integer Dim FoundCode As Integer Dim i As Integer i = 1 FoundCode = -1 Do If SearchCode = PCode(i) Then FoundCode = i Else i = i + 1 End If Loop Until i = 1001 Or FoundCode <> -1 Return FoundCode End Function
Mark scheme, page 13
Page 13 Mark Scheme Syllabus Paper Cambridge International AS/A Level – October/November 2016 9608 23 © UCLES 2016 4(e): Pascal Function ProductCodeSearch (SearchCode : String): integer; var FoundCode, ThisIndex : integer; Found : Boolean; Begin Found := false; ThisIndex := 1; Repeat If SearchCode = PCode[ThisIndex] then Begin FoundCode := ThisIndex; Found := true; Else ThisIndex := ThisIndex + 1; end; Until (ThisIndex = 1001) OR (Found); If Found = false then FoundCode := -1 ProductCodeSearch := FoundCode; end. 4(e): Python def ProductCodeSearch(SearchCode): # list indexes start at zero i = 0 Found = "no" while not(i == 1001 or Found == "yes"): if SearchCode == PCode[i]: Found = "yes" FoundIndex = i else: i = i + 1 if Found == "no": FoundIndex = -1 return FoundIndex
What you needed in this session
Cambridge’s own grade thresholds for 2016 Oct/Nov, Paper 2 · Variant 3. A higher threshold means an easier paper — the bar moves with how the cohort did.