Cambridge A Level Computer Science 9618 — 2023 May/June Paper 2 · Variant 1
9618/21/M/J/23 · 8 questions · 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 scheme11 pages
Answers below. Sit the paper first if you are practising.











Questions as text
Q1 · A programmer has written a program which includes the function Calculate()
1 A programmer has written a program which includes the function Calculate(). When the program is run, the function returns an unexpected value. (a) Describe how a typical Integrated Development Environment (IDE) could be used to help debug the program to find the errors in the function Calculate(). ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ............................................................................................................................................. [4] (b) The algorithm for function Calculate() contains the three pseudocode statements shown. Describe the error in each statement or write ‘no error’ if the statement contains no error. Assume any variables used are of the correct type for the given function. Statement 1: Index STR_TO_NUM(("27") + 2) Error .......................................................................................................................................... ................................................................................................................................................... Statement 2: Index STR_TO_NUM(MID("CPE1704TKS", 4, 2)) Error .......................................................................................................................................... ................................................................................................................................................... Statement 3: IF MONTH(ThisDate) > '6' THEN Error .......................................................................................................................................... ................................................................................................................................................... [3] (c) The program contains variables with values as follows: Variable Value Active TRUE Points 75 Exempt FALSE (i) Complete the table by evaluating each expression. Expression Evaluation 1 (Points > 99) OR Active 2 (Points MOD 2 = 0) OR Exempt 3 (Points <= 75) AND (Active OR Exempt) 4 (Active OR NOT Active) AND NOT Exempt [2] (ii) Write expression 4 from the table in part (c)(i) in its simplest form. ..................................................................................................................................... [1]
Mark scheme: Question Answer Marks 1(a) For example: 4 Could set a breakpoint to stop the program at a particular point / instruction then the value of variables could be checked using a report/watch window while single stepping can be used to execute one statement/line at a time. Marks available as follows: One mark for each underlined term One mark for an explanation of each term Note: max 4 marks 1(b) One mark for correct description of: 3 Error 1: Brackets mismatch // 2/value should be added after brackets/function // Addition between a string and a number is not valid // STR_TO_NUM / the function needs to be passed a string / not an integer Error 2: No Error Error 3: MONTH() returns an integer and this is being compared with a character/string // Integer cannot be compared to a string // 6 should not be in quotes 1(c)(i) 2 Expression Evaluation 1 (Points > 99) OR Active TRUE 2 (Points MOD 2 = 0) OR Exempt FALSE 3 (Points <= 75) AND (Active OR Exempt) TRUE 4 (Active OR NOT Active) AND NOT Exempt TRUE One mark for any two rows correct Two marks for all rows correct 1(c)(ii) NOT Exempt 1
Q2 · A program contains an algorithm to output a string of a specified length containing…
2 A program contains an algorithm to output a string of a specified length containing identical characters. (a) The algorithm is described as follows: 1. prompt and input a character and store in MyChar 2. prompt and input an integer and store in MyCount 3. generate a string consisting of MyChar repeated MyCount times 4. output the string. Draw a program flowchart to represent the algorithm. START END [4] (b) A different part of the program uses the variable StartDate. Write pseudocode statements to declare StartDate and assign to it the date corresponding to 15/11/2005. Declaration ............................................................................................................................... Assignment ............................................................................................................................... [3]
Mark scheme: 2(a) 4 One mark per point: 1 Both prompts 2 Both inputs using correct identifiers as given in question, MyChar and MyCount 3 Initialise MyString to empty string and subsequent output after loop 4 Loop MyCount iterations including decrement MyCount 5 Use of Concatenate or equivalent pseudocode statement inside loop Max 4 Marks 2(b) One mark for declaration: 3 DECLARE StartDate : DATE One mark for each underlined part of assignment: StartDate SETDATE (15, 11, 2005)
Q3 · Customers collect points every time they make a purchase at a store
3 Customers collect points every time they make a purchase at a store. A program is used to manage the points system and the table lists some of the information stored for one customer. Information Data type required Name String Number of points collected Integer Date of birth Date (a) (i) Identify a suitable structure for storing the information for one customer. Explain the advantage of using this structure. Structure ............................................................................................................................ Advantage ......................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... [4] (ii) Describe a data structure that could be used to store the information for all customers. ........................................................................................................................................... ..................................................................................................................................... [2] (b) Customers receive points depending on the amount they spend. The number of points depends on the band that the amount falls into: Band Amount Points 1 Less than $10 5 per whole dollar ($) 2 Between $10 and $100 inclusive 7 per whole dollar ($) 3 Over $100 10 per whole dollar ($) For example, if the amount is $99.77, this amount is in band 2 and therefore the number of points is 7 × 99, which is 693 points. The algorithm to calculate the points from a given amount is expressed as follows: • work out the appropriate band • calculate and output the number of points. Apply the process of stepwise refinement to increase the detail of the algorithm. Structure your algorithm into a sequence of five steps that could be used to produce pseudocode. Write the five steps. 1 ................................................................................................................................................ ................................................................................................................................................... ................................................................................................................................................... 2 ................................................................................................................................................ ................................................................................................................................................... ................................................................................................................................................... 3 ................................................................................................................................................ ................................................................................................................................................... ................................................................................................................................................... 4 ................................................................................................................................................ ................................................................................................................................................... ................................................................................................................................................... 5 ................................................................................................................................................ ................................................................................................................................................... ...................................................................................................................................................
Mark scheme: 3(a)(i) One mark for structure 4 Structure: Record One mark for each point Advantage: A set of data / all data related to one customer of different types is held under a single identifier/entity 3(a)(ii) A (1D) array of records // An array of the given type could be used 2 One mark per underlined word 3(b) One mark for reference to each: 5 1 Reference to the use of constants or variables for the two threshold values of 10 and 100 // Input amount spent (by customer and store in a numeric variable) 2 Work out one band that amount maps to 3 Work out all bands that amount maps to 4 Calculate rounded value of amount / whole number part of amount 5 Calculate the points by multiplying the (rounded) amount by the appropriate value for appropriate band /all bands 6 Output the number of points Note: Max 5 from available points
Q4 · Function Replace() will: 1
4 Function Replace() will: 1. take three parameters: • a string (the original string) • a char (the original character) • a char (the new character) 2. form a new string from the original string where all instances of the original character are replaced by the new character 3. return the new string. Write pseudocode for function Replace(). .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .................................................................................................................................................... [6]
Mark scheme: 4 Function Replace(OldString : STRING, Char1, Char2 : 6 CHAR) __ RETURNS : STRING DECLARE NewString : STRING DECLARE ThisChar : CHAR DECLARE Index : INTEGER NewString "" FOR Index 1 TO LENGTH(OldString) ThisChar MID(OldString, Index, 1) IF ThisChar = Char1 THEN ThisChar Char2 ENDIF NewString NewString & ThisChar NEXT Index RETURN NewString ENDFUNCTION Mark as follows: 1 Function heading and ending, including parameters and return type 2 Declaration of local variables used including loop counter 3 Loop for length of OldString 4 Extract char and test in a loop 5 Use of concatenate to build NewString replace char if necessary, in a loop 6 Return NewString after reasonable attempt
Q5 · Several companies are developing websites to market a new type of games console
5 Several companies are developing websites to market a new type of games console. The company that is first to create a website that can demonstrate the interactive features of the games console will have an advantage over the others. The requirements for the website are likely to change as more information about the features of the console are made available. One company has decided to develop their website using a program development life cycle based on the waterfall model. (a) (i) Give two reasons why this may not be the most appropriate model to use in this case. Reason 1 ........................................................................................................................... ........................................................................................................................................... Reason 2 ........................................................................................................................... ........................................................................................................................................... [2] (ii) Identify a more appropriate program development life cycle model for this scenario. ..................................................................................................................................... [1] (b) The website has been running in test mode for several weeks. Identify and describe a final stage of testing that should take place before the website is made available to all customers. Stage ........................................................................................................................................ Description ................................................................................................................................ ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... [3]
Mark scheme: 5(a)(i) Reasons include: 2 1 No working software until late in the life cycle so slower to market than competitors // Does not allow the creation of early versions/prototypes (which can be updated later) 2 More difficult/slower to cope with changes to the requirements // website slower to be updated to reflect new requirements 3 Needs high involvement/feedback of the stake holders /customer / client One mark per point Max 2 marks 5(a)(ii) Iterative / Rapid Application Development / RAD 1 5(b) One mark for Stage 3 Stage: Beta testing Max 2 marks for Description Description: 1 Testing carried out by a small group of (potential) users 2 Users will check that the website/software works as required / works in the real world //User will identify errors in the website/software 3 Users will feedback (problems) / suggestions for improvement 4 Problems / suggestions identified are addressed (before the program is sold)
Q6 · A video-conferencing program supports up to six users
6 A video-conferencing program supports up to six users. Speech from each user is sampled and digitised (converted from analogue to digital). Digitised values are stored in array Sample. The array Sample consists of 6 rows by 128 columns and is of type integer. Each row contains 128 digitised sound samples from one user. The digitised sound samples from each user are to be processed to produce a single value which will be stored in a 1D array Result of type integer. This process will be implemented by procedure Mix(). A procedure Mix() will: • calculate the average of each of the 6 sound samples in a column • ignore sound sample values of 10 or less • store the average value in the corresponding position in Result • repeat for each column in array Sample The diagram uses example values to illustrate the process: 1 2 3 ... 126 127 128 1 20 20 20 30 30 2 2 20 20 30 50 30 3 3 20 20 40 40 40 4 Sample: 4 20 20 50 40 50 20 5 20 3 5 6 60 4 6 20 4 2 4 70 30 Result: 20 20 35 40 46 25 Write pseudocode for procedure Mix(). Assume Sample and Result are global. .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .................................................................................................................................................... [6]
Mark scheme: 6 PROCEDURE Mix() 6 DECLARE Count, Total ThisNum : INTEGER DECLARE ThisUser, ThisSample : INTEGER FOR ThisSample 1 TO 128 Count 0 Total 0 FOR ThisUser 1 TO 6 IF Sample[ThisUser, ThisSample] > 10 THEN Count Count + 1 Total Total + Sample[ThisUser, ThisSample] ENDIF NEXT ThisUser Result[ThisSample] INT(Total / Count) NEXT ThisSample ENDPROCEDURE Mark as follows: 1 Declaration and initialisation before inner loop of Count and Total 2 Outer Loop for 128 iterations 3 Inner loop for six iterations 4 Test for sample > 10 in a loop 5 and if true sum Total and increment Count 6 Calculate average value and assign to Result array after inner loop and within outer loop 7 Use of INT()/ DIV to convert average to integer Max 6 Marks
Q7 · A school has a computerised library system that allows students to borrow books for a…
7 A school has a computerised library system that allows students to borrow books for a fixed length of time. The system uses text files to store details of students, books and loans. A new module is to be written which will generate emails to each student who has an overdue book. (a) Decomposition will be used to break down the problem of designing the new module into sub-problems. Identify three program modules that could be used in the design and describe their use. Module 1 ................................................................................................................................... Use ........................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... Module 2 ................................................................................................................................... Use ........................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... Module 3 ................................................................................................................................... Use ........................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... [3] (b) The program designer produces a structure chart for the new module. Part of the structure chart is shown: Module-A() Module-B() Module-C() Module-D() (i) Explain the relationship between the four modules shown. ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ..................................................................................................................................... [2] (ii) Two new modules are added: Module‑X() and Module‑Y(). • Module‑X() has no parameters. • Module‑Y() will take a string and a real number as parameters and return a Boolean value. • Module‑D() will call either Module‑X() or Module‑Y(). Draw only the part of the structure chart that represents the relationship between Module‑X(), Module‑Y() and Module‑D(). [3]
Mark scheme: 7(a) Examples include: 3 Module: GetOverdueLoan() Use: Identifies an overdue book Module: IdentifyStudent() Use: Identifies a student (with an overdue book)1 Module: GetStudentEmail() Use: Gets the email address of a student with an overdue book Module: CreateEmail() Use: Generates an email to a student with an overdue book Module: SendEmail() Use: Sends an email to a student with an overdue book One mark for name and use Note: Max 3 marks 7(b)(i) One mark per point: 2 Module-A calls the other three modules The process is repeated 7(b)(ii) 3 One mark per bullet point: All rectangles correctly labelled and interconnected All and only parameters as shown Selection diamond
Q8 · A computer shop assembles computers using items bought from several suppliers
8 A computer shop assembles computers using items bought from several suppliers. A text file Stock.txt contains information about each item. Information for each item is stored as a single line in the Stock.txt file in the format: <ItemNum><SupplierCode><Description> Item information is as follows: Format Comment unique for each item in the range ItemNum 4 numeric characters "0001" to "5999" inclusive SupplierCode 5 alphabetic characters to identify the supplier of the item Description a string a minimum of 12 characters The file is organised in ascending order of ItemNum and does not contain all possible values in the range. A programmer has started to define program modules as follows: Module Description SuppExists() • called with a parameter of type string representing a supplier code (already written) • returns TRUE if the supplier code is already in use, otherwise returns FALSE IsNewSupp() • called with a parameter of type string representing a new supplier code • returns TRUE if the string only contains alphabetic characters (either upper or lower case) and the supplier code is not already in use, otherwise returns FALSE (a) Write pseudocode for module IsNewSupp(). Module SuppExists() has already been written and should be used as part of your solution. Module SuppExists() will generate a run-time error if the given parameter is not 5 characters in length. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ............................................................................................................................................. [7] (b) A new module has been defined: Module Description CheckNewItem() • called with a parameter of type string representing a line of item information • checks to see whether an item with the same ItemNum already exists in the file • returns TRUE if the ItemNum is not already in the file, otherwise returns FALSE Write efficient pseudocode for module CheckNewItem(). ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ...................................................................................................................................................
Mark scheme: 8(a) FUNCTION IsNewSupp(ThisString : STRING) RETURNS BOOLEAN 7 DECLARE Index : INTEGER DECLARE ThisChar : CHAR IF LENGTH(ThisString) <> 5 THEN RETURN FALSE // invalid SupplierCode length ENDIF IF SuppExists(ThisString) THEN RETURN FALSE // SupplierCode already exists ENDIF FOR Index 1 TO 5 ThisChar TO_LOWER(MID(ThisString, Index, 1)) IF ThisChar < 'a' OR ThisChar > 'z'THEN RETURN FALSE ENDIF NEXT Index RETURN TRUE ENDFUNCTION Mark as follows: 1 Check ThisString is exactly 5 characters in length 2 Use of SuppExists() with a string of 5 characters as a parameter 3 Loop for 5 iterations // loops for length of string parameter 4 Extract a character in a loop 5 Test if char is alphabetic in a loop 6 …catering for both upper and lower case 7 Return Boolean following a reasonable attempt 8(b) FUNCTION CheckNewItem(NewLine : STRING) RETURNS BOOLEAN 7 DECLARE NotFound : BOOLEAN DECLARE NewItemNum, ThisItemNum, ThisLine : STRING NotFound TRUE OPENFILE "Stock.txt" FOR READ NewItemNum LEFT(NewLine, 4) ThisItemNum "0000" //rogue initial value WHILE NOT EOF("Stock.txt") AND NotFound = TRUE AND__ ThisItemNum < NewItemNum READFILE("Stock.txt", ThisLine) //brackets optional ThisItemNum LEFT(ThisLine, 4) IF ThisItemNum = NewItemNum THEN NotFound FALSE ENDIF ENDWHILE CLOSEFILE "Stock.txt" RETURN NotFound ENDFUNCTION Mark as follows: 1 Open Stock.txt in READ mode and subsequently close 2 Extract NewItemNum from parameter 3 Conditional loop until EOF("Stock.txt") 4 ... OR NewItemNum found 5 ... OR when ThisItemNum < NewItemNum 6 Read a line from Stock.txt AND extract ThisItemNum in a loop 7 If ThisItemNum = NewItemNum then terminate loop / set flag in a loop 8 Return Boolean after reasonable attempt Max 7 marks Max 6 if function wrapper (heading and ending) missing or incorrect 8(c)(i) Integration testing 1 8(c)(ii) Two marks for the description: 2 A dummy/simple module is written to replace the module that does not work properly The dummy/simple module will return an expected value // will output a message to show it has been called 8(d) Append 1 8(e) One mark for each part: 3 The algorithm / search / iteration can stop /only iterates if the current value read from the file // current line in file is greater than the value being searched for
What was in this paper
The subtopics covered by these 8 questions, and how many questions each got. Open one in a new tab to see every Cambridge question on it.
What you needed in this session
Cambridge’s own grade thresholds for 2023 May/June, Paper 2 · Variant 1. A higher threshold means an easier paper — the bar moves with how the cohort did.