TopicalComputer Science 9618Software DevelopmentProgram DesignPaper 2

Program Design — Paper 2 · A Level Computer Science 9618

12.2· 12 questions · 109 marks · 131 min · 2021–2023· Structured questions

Every Cambridge A Level Computer Science Paper 2 question on program design, laid out as 21 A4 pages with the mark scheme below. Nothing is left out. Free to read, no account.

Different topic or paper

Questions21 pages

Question 1: (a) Four program modules form part of a program for a library. A description of the relationship between the modules is summarised as follo…1 / 21
Question 1 (continued)2 / 21
Question 1 (continued)3 / 21
Question 2: (a) Four program modules form part of a program for a library. A description of the relationship between the modules is summarised as follo…4 / 21
Question 2 (continued)5 / 21
Question 2 (continued)6 / 21
Question 3: The following data items will be recorded each time a student successfully logs on to the school network: Data item Example data Student ID…7 / 21
Question 3 (continued)Question 4: (a) An algorithm will: 1. input an integer value 2. jump to step 6 if the value is zero 3. sum and count the positive values 4. sum and cou…8 / 21
Question 4 (continued)9 / 21
Question 4 (continued)Question 5: The following data items will be recorded each time a student successfully logs on to the school network: Data item Example data Student ID…10 / 21
Question 5 (continued)11 / 21
Question 6: (a) A programmer is testing a program using an Integrated Development Environment (IDE). The programmer wants the program to stop when it r…12 / 21
Question 7: (a) The module headers for five modules in a program are defined in pseudocode as follows: Pseudocode module header FUNCTION Mod_V(S2 : INT…13 / 21
Question 7 (continued)14 / 21
Question 8: Four program modules are defined as follows: Pseudocode module header PROCEDURE Sub1_A(XT : INTEGER, PB : STRING) FUNCTION Sub1_B(RA : INTE…15 / 21
Question 9: A program is being designed for a smartphone to allow users to send money to the charity of their choice. Decomposition will be used to bre…Question 10: A program contains an algorithm to output a string of a specified length containing identical characters. (a) The algorithm is described as…16 / 21
Question 10 (continued)17 / 21
Question 11: 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 s…18 / 21
Question 11 (continued)Question 12: A school has a library system which allows students to borrow books for a length of time. Information relating to students and books is sto…19 / 21
Question 12 (continued)20 / 21
Question 12 (continued)21 / 21

Mark scheme12 answers

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

Pastlit

Computer Science 9618 · Program Design — Paper 2

A Level · topical answer key — answer key (teacher use)

Question

Answer

Marks

1Mark scheme for question 113
2Mark scheme for question 213
3Mark scheme for question 310
4Mark scheme for question 410
5Mark scheme for question 510
6Mark scheme for question 611
7Mark scheme for question 79
8Mark scheme for question 87
9Mark scheme for question 93
10Mark scheme for question 107
11Mark scheme for question 118
12Mark scheme for question 128
QuestionAnswerMarksFrom
1see sheet139618/21 May/June 2021
2see sheet139618/23 May/June 2021
3see sheet109618/21 Oct/Nov 2021
4see sheet109618/22 Oct/Nov 2021
5see sheet109618/23 Oct/Nov 2021
6see sheet119618/22 May/June 2022
7see sheet99618/22 May/June 2022
8see sheet79618/23 May/June 2022
9see sheet39618/23 Oct/Nov 2022
10see sheet79618/21 May/June 2023
11see sheet89618/21 May/June 2023
12see sheet89618/23 May/June 2023

Another paper, or another topic

Paper
Paper 212 questionsPaper 3questions coming

All of Software Development

Questions as text

Q1 · Four program modules form part of a program for a library 9618/21 May/June 2021

2 (a) Four program modules form part of a program for a library. A description of the relationship between the modules is summarised as follows: Module name Description UpdateLoan() • Calls either LoanExtend() or LoanReturn() • Called with parameters LoanID and BookID • Calls CheckReserve() to see whether the book has been LoanExtend() reserved for another library user • Returns TRUE if the loan has been extended, otherwise returns FALSE • Called with BookID CheckReserve() • Returns TRUE if the book has been reserved, otherwise returns FALSE • Called with parameters LoanID and BookID LoanReturn() • Returns a REAL (which is the value of the fine to be paid in the case of an overdue loan) Draw a structure chart to show the relationship between the four modules and the parameters passed between them. [5] (b) The definition for module LoanReturn() is amended as follows: Module name Description Called with parameters LoanID, BookID and Fine LoanReturn() The module code checks whether the book has been returned on time and then assigns a new value to Fine • LoanID and BookID are of type STRING • Fine is of type REAL Write the pseudocode header for the amended module LoanReturn(). … … [2] (c) A program will: • input 50 unique integer values • output the largest value • output the average of the values excluding the largest value. Draw a program flowchart to represent the algorithm. Variable declarations are not required. It is not necessary to check that each input value is unique. [6]

13 marks

Mark scheme: 2(a) 5 One mark for: 1 All four boxes correctly labelled and positioned 2 Selection diamond (only on UpdateLoan and no iteration arrows) 3 Parameters to and from LoanExtend() 4 Parameters to and from CheckReserve() 5 Parameters to and from LoanReturn() 2(b) PROCEDURE LoanReturn (LoanID, BookID : STRING, 2 BYREF Fine : REAL) One mark for each underlined part 2(c) Example solution: 6 One mark for each functional group as listed below: 2(c) Explanation of mark points: 1 Initialise MAX to first value input 2 Set Total to zero 3 Input 49 more values (or 50 values in total) 4 Sum all values input 5 Set new MAX when Input value > MAX in a loop 6 Sum all but largest (or subtract MAX from total), calculate and output average

This question in 9618/21 May/June 2021

Q2 · Four program modules form part of a program for a library 9618/23 May/June 2021

2 (a) Four program modules form part of a program for a library. A description of the relationship between the modules is summarised as follows: Module name Description UpdateLoan() • Calls either LoanExtend() or LoanReturn() • Called with parameters LoanID and BookID • Calls CheckReserve() to see whether the book has been LoanExtend() reserved for another library user • Returns TRUE if the loan has been extended, otherwise returns FALSE • Called with BookID CheckReserve() • Returns TRUE if the book has been reserved, otherwise returns FALSE • Called with parameters LoanID and BookID LoanReturn() • Returns a REAL (which is the value of the fine to be paid in the case of an overdue loan) Draw a structure chart to show the relationship between the four modules and the parameters passed between them. [5] (b) The definition for module LoanReturn() is amended as follows: Module name Description Called with parameters LoanID, BookID and Fine LoanReturn() The module code checks whether the book has been returned on time and then assigns a new value to Fine • LoanID and BookID are of type STRING • Fine is of type REAL Write the pseudocode header for the amended module LoanReturn(). … … [2] (c) A program will: • input 50 unique integer values • output the largest value • output the average of the values excluding the largest value. Draw a program flowchart to represent the algorithm. Variable declarations are not required. It is not necessary to check that each input value is unique. [6]

13 marks

Mark scheme: 2(a) 5 One mark for: 1 All four boxes correctly labelled and positioned 2 Selection diamond (only on UpdateLoan and no iteration arrows) 3 Parameters to and from LoanExtend() 4 Parameters to and from CheckReserve() 5 Parameters to and from LoanReturn() 2(b) PROCEDURE LoanReturn (LoanID, BookID : STRING, 2 BYREF Fine : REAL) One mark for each underlined part 2(c) Example solution: 6 One mark for each functional group as listed below: 2(c) Explanation of mark points: 1 Initialise MAX to first value input 2 Set Total to zero 3 Input 49 more values (or 50 values in total) 4 Sum all values input 5 Set new MAX when Input value > MAX in a loop 6 Sum all but largest (or subtract MAX from total), calculate and output average

This question in 9618/23 May/June 2021

Q3 · The following data items will be recorded each time a student successfully logs on to the… 9618/21 Oct/Nov 2021

5 The following data items will be recorded each time a student successfully logs on to the school network: Data item Example data Student ID "CJL404" Host ID "Lib01" Time and date "08:30, June 01, 2021" The Student ID is six characters long. The other two data items are of variable length. A single string will be formed by concatenating the three data items. A separator character will need to be inserted between items two and three. For example: "CJL404Lib01<separator>08:30, June 01, 2021" Each string represents one log entry. A programmer decides to store the concatenated strings in a 1D array LogArray that contains 2000 elements. Unused array elements will contain an empty string. (a) Suggest a suitable separator character and give a reason for your choice. Character … Reason … … [2] (b) The choice of data structure was made during one stage of the program development life cycle. Identify this stage. … [1] (c) A function LogEvents() will: • take a Student ID as a parameter • for each element in the array that matches the Student ID parameter: ◦ add the value of the array element to the existing text file LogFile ◦ assign an empty string to the array element • count the number of lines added to the file • return this count. Write pseudocode for the function LogEvents(). … … … … … … … … … … … … … … … … … … … … … … … … [7]

10 marks

Mark scheme: 5(a) One mark for the character and one for the corresponding reason. 2 • Character: Any except alphabetic, numeric, ',' ':' or space • Reason: character doesn't occur in data to be recorded 5(b) Design 1 5(c) FUNCTION LogEvents(StudentID : STRING) RETURNS INTEGER 7 DECLARE FileData : STRING DECLARE Index, Count : INTEGER CONSTANT LogFile = "LogFile" Count ← 0 OPENFILE LogFile FOR APPEND FOR Index ← 1 TO 2000 FileData ← LogArray[Index] IF LEFT(FileData, 6) = StudentID THEN WRITEFILE (LogFile, FileData) //brackets optional Count ← Count + 1 LogArray[Index] ← "" // clear the element ENDIF NEXT Index CLOSEFILE LogFile RETURN Count ENDFUNCTION 1 mark for each of the following: 1 Function heading and ending including parameter and return type 2 OPEN file LogFile for APPEND and subsequent CLOSE 3 Loop for 2000 iterations 4 Extract first 6 characters from array element in a loop 5 Compare first 6 characters with parameter in a loop 6 If equal: • write whole array element string to file and • increment Count and • clear array element in a loop 7 Return Count (must have been declared and initialised)

This question in 9618/21 Oct/Nov 2021

Q4 · An algorithm will: 1 9618/22 Oct/Nov 2021

2 (a) An algorithm will: 1. input an integer value 2. jump to step 6 if the value is zero 3. sum and count the positive values 4. sum and count the negative values 5. repeat from step 1 6. output the two sum values and the two count values. Draw a program flowchart on the following page to represent the algorithm. Note that variable declarations are not required in program flowcharts. [5] (b) A software company is working on a project to develop a website for a school. The school principal has some ideas about the appearance of the website but is unclear about all the details of the solution. The principal would like to see an initial version of the website. (i) Identify a life cycle method that would be appropriate in this case. Give a reason for your choice. Life cycle method … Reason … … … … [2] (ii) The website project has progressed to the design stage. State three activities that will take place during the design stage of the program development life cycle. 1 … 2 … 3 … [3]

10 marks

Mark scheme: 2(a) 5 One mark for each outlined group. Note: • Sum and increment steps (bottom-right rectangles) may be in reverse order in which case sum group will have two output lines • Max 4 for non-working solution 2(b)(i) One mark for each: 2 Life cycle method: Iterative // Rapid Application Development (RAD) Reason: Provides a working model / prototype at an early stage for the principal to approve / review 2(b)(ii) Decisions will be made regarding: 3 • Data structures • Algorithms / flowcharts / pseudocode • Program structure (modules) / use of library routines / module - team allocation • User interface // Web-page layout / content (for given scenario) • Testing method / plan • Choice of programming language / program environment Max 3

This question in 9618/22 Oct/Nov 2021

Q5 · The following data items will be recorded each time a student successfully logs on to the… 9618/23 Oct/Nov 2021

5 The following data items will be recorded each time a student successfully logs on to the school network: Data item Example data Student ID "CJL404" Host ID "Lib01" Time and date "08:30, June 01, 2021" The Student ID is six characters long. The other two data items are of variable length. A single string will be formed by concatenating the three data items. A separator character will need to be inserted between items two and three. For example: "CJL404Lib01<separator>08:30, June 01, 2021" Each string represents one log entry. A programmer decides to store the concatenated strings in a 1D array LogArray that contains 2000 elements. Unused array elements will contain an empty string. (a) Suggest a suitable separator character and give a reason for your choice. Character … Reason … … [2] (b) The choice of data structure was made during one stage of the program development life cycle. Identify this stage. … [1] (c) A function LogEvents() will: • take a Student ID as a parameter • for each element in the array that matches the Student ID parameter: ◦ add the value of the array element to the existing text file LogFile ◦ assign an empty string to the array element • count the number of lines added to the file • return this count. Write pseudocode for the function LogEvents(). … … … … … … … … … … … … … … … … … … … … … … … … [7]

10 marks

Mark scheme: 5(a) One mark for the character and one for the corresponding reason. 2 • Character: Any except alphabetic, numeric, ',' ':' or space • Reason: character doesn't occur in data to be recorded 5(b) Design 1 5(c) FUNCTION LogEvents(StudentID : STRING) RETURNS INTEGER 7 DECLARE FileData : STRING DECLARE Index, Count : INTEGER CONSTANT LogFile = "LogFile" Count ← 0 OPENFILE LogFile FOR APPEND FOR Index ← 1 TO 2000 FileData ← LogArray[Index] IF LEFT(FileData, 6) = StudentID THEN WRITEFILE (LogFile, FileData) //brackets optional Count ← Count + 1 LogArray[Index] ← "" // clear the element ENDIF NEXT Index CLOSEFILE LogFile RETURN Count ENDFUNCTION 1 mark for each of the following: 1 Function heading and ending including parameter and return type 2 OPEN file LogFile for APPEND and subsequent CLOSE 3 Loop for 2000 iterations 4 Extract first 6 characters from array element in a loop 5 Compare first 6 characters with parameter in a loop 6 If equal: • write whole array element string to file and • increment Count and • clear array element in a loop 7 Return Count (must have been declared and initialised)

This question in 9618/23 Oct/Nov 2021

Q6 · A programmer is testing a program using an Integrated Development Environment (IDE) 9618/22 May/June 2022

1 (a) A programmer is testing a program using an Integrated Development Environment (IDE). The programmer wants the program to stop when it reaches a specific instruction or program statement in order to check the value assigned to a variable. Give the technical term for the position at which the program stops. … [1] (b) The following table lists some activities from the program development life cycle. Complete the table by writing the life cycle stage for each activity. Activity Life cycle stage An identifier table is produced. Syntax errors can occur. The developer discusses the program requirements with the customer. A trace table is produced. [4] (c) An identifier table includes the names of identifiers used. State two other pieces of information that the identifier table should contain. 1 … 2 … [2] (d) The pseudocode statements in the following table may contain errors. State the error in each case or write 'NO ERROR' if the statement contains no error. You can assume that none of the variables referenced are of an incorrect type. Statement Error Status TRUE AND FALSE IF LENGTH("Password") < "10" THEN Code LCASE("Electrical") Result IS_NUM(-27.3) [4]

11 marks

Mark scheme: Question Answer Marks 1(a) Correct answer only: 1 Breakpoint 1(b) One mark per row 4 Activity Life cycle stage An identifier table is produced. Design Syntax errors can occur. Coding The developer discusses the program requirements with the Analysis customer. A trace table is produced. Testing 1(c) One mark per bullet point to Max 2 2  A description of what the identifier is used for / the purpose of the identifier  The data type of the identifier  The number of elements of an array // the length of a string  An example data value  Value of any constants used  The scope of the variable (local or global) 1(d) One mark per row 4 Statement Error Status  TRUE AND FALSE NO ERROR IF LENGTH("Password") < "10" shouldn’t be a string // must be an "10" THEN integer Code  Parameter must be a char // cannot be a LCASE("Electrical") string Alternative: LCASE should be TO_LOWER Result  IS_NUM(-27.3) Parameter must be a string / char // cannot be a number

This question in 9618/22 May/June 2022

Q7 · The module headers for five modules in a program are defined in pseudocode as follows… 9618/22 May/June 2022

3 (a) The module headers for five modules in a program are defined in pseudocode as follows: Pseudocode module header FUNCTION Mod_V(S2 : INTEGER) RETURNS BOOLEAN PROCEDURE Mod_W(P4 : INTEGER) PROCEDURE Mod_X(T4 : INTEGER, BYREF P3 : REAL) PROCEDURE Mod_Y(W3 : REAL, Z8 : INTEGER) FUNCTION Mod_Z(F3 : REAL) RETURNS INTEGER An additional module Head() repeatedly calls three of the modules in sequence. A structure chart has been partially completed. (i) Complete the structure chart to include the information given about the six modules. Do not label the parameters and do not write the module names. A B C D E F [3] (ii) Complete the table using the information in part 3(a) by writing each module name to replace the labels A to F. Label Module name A B C D E F [3] (b) The structure chart represents part of a complex problem. The process of decomposition is used to break down the complex problem into sub-problems. Describe three benefits of this approach. 1 … … 2 … … 3 … … [3]

9 marks

Mark scheme: 3(a)(i) One mark per red annotation 3 3(a)(ii) 3 Label Module name A Head B Mod_W C Mod_X D Mod_V E Mod-Z F Mod_Y Marks as follows:  Two rows correct – one mark  Four rows correct – two marks  All rows correct – three marks 3(b) One mark per point: 3  Breaking a complex problem down makes it easier to understand / solve // smaller problems are easier to understand / solve  Smaller problems are easier to program / test / maintain  Sub-problems can be given to different teams / programmers with different expertise // can be solved separately

This question in 9618/22 May/June 2022

Q8 · Four program modules are defined as follows: Pseudocode module header PROCEDURE Sub1_A(XT… 9618/23 May/June 2022

3 Four program modules are defined as follows: Pseudocode module header PROCEDURE Sub1_A(XT : INTEGER, PB : STRING) FUNCTION Sub1_B(RA : INTEGER) RETURNS BOOLEAN PROCEDURE Sub1_C(SB : INTEGER, BYREF SA : STRING) PROCEDURE Section_1() (a) A structure chart will be produced as part of the development process. Describe the purpose of a structure chart. … … … … [2] (b) Module Section_1() calls one of the other three modules. The module called will be selected when the program runs. Draw the structure chart. [5]

7 marks

Mark scheme: 3(a) One mark per point to show: 2  module relationships / hierarchy / selection / repetition // how a problem is broken down  the parameters that are passed between the sub-tasks / modules // whether a module is a function or a procedure 3(b) 5 One mark for each: 1 Four boxes linked as shown correctly labelled (Order of lower 3 not important) 2 Parameters to Sub1_A 3 Parameter to Sub1_B and return value 4 Parameters to Sub1_C 5 Selection diamond

This question in 9618/23 May/June 2022

Q9 · A program is being designed for a smartphone to allow users to send money to the charity… 9618/23 Oct/Nov 2022

2 A program is being designed for a smartphone to allow users to send money to the charity of their choice. Decomposition will be used to break the problem down 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]

3 marks

Mark scheme: 2 One mark for name and two marks for use (Max 3 in total): 3 Examples include: Module: SelectCharity() Use: Allows the user to choose a particular charity Module: SpecifyAmountAndType() Use: Allows the user to specify a single or regular payment Module: MakePayment() Use: Make payment to the charity Module: ValidatePayment() Use: Validate payment details (by accessing bank computer) Module: AddBankAccountDetails() / AddPaymentDetails() Use: Allows the user to add bank account information that donation to be taken from Module: AddDonorDetails() Use: Allows user to add details such as name and contact details

This question in 9618/23 Oct/Nov 2022

Q10 · A program contains an algorithm to output a string of a specified length containing… 9618/21 May/June 2023

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]

7 marks

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)

This question in 9618/21 May/June 2023

Q11 · A school has a computerised library system that allows students to borrow books for a… 9618/21 May/June 2023

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]

8 marks

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

This question in 9618/21 May/June 2023

Q12 · A school has a library system which allows students to borrow books for a length of time 9618/23 May/June 2023

7 A school has a library system which allows students to borrow books for a length of time. Information relating to students and books is stored in text files. Student information includes name, home address, email address, date of birth, tutor and subject choices. Book information includes author, title, subject category, library location and the date that the book was borrowed. A program helps the staff to manage the borrowing of books. (a) A new module needs to be written to generate emails to send to students who have an overdue book. Students who are sent an email are prevented from borrowing any more books until the overdue book is returned. The process of abstraction has been used when designing the new module. (i) State the purpose of applying abstraction to this problem. … … [1] (ii) Identify one item of information that is required and one item that is not required in the new module. Justify your choices. Item required … Justification … … … Item not required … Justification … … … [2] (iii) Identify two operations that would be required to process data when an overdue book is returned. Operation 1 … … Operation 2 … … [2] (b) Part of the library program contains program modules with headers as follows: Pseudocode module header PROCEDURE Module-X() PROCEDURE Module-Y(BYREF RA : INTEGER, SA : REAL) PROCEDURE Overlay() FUNCTION Replace(RA : INTEGER, RB : BOOLEAN) RETURNS BOOLEAN FUNCTION Reset(TA : STRING) RETURNS INTEGER Module-X() and Module-Y() are both called from module Overlay(). Complete the structure chart. [3]

8 marks

Mark scheme: 7(a)(i)  To filter out information (that is not necessary to solve the problem) // 1 to include only essential information 7(a)(ii) Required: 2 Student : Student name / email (address) Loan: Return/Issue date Book: Book title Not Required: Student: Home address / DoB / tutor / subject choices Book: Library location / category / author / book title 7(a)(iii) Max 2 marks 2 Examples could include:  Clear the loan // indicate that the book has been returned // update loan history  Take the student off 'block' // allow the student to borrow further books  Send acknowledgement to the student when book is returned 7(b) Max 3 marks 3 MP1 All modules correctly labelled and interconnected. MP2 Correct parameters and return type to Module-X and Reset MP3 Correct parameters and return type to Module-Y and Replace MP4 Correct parameters and return type to Overlay and Module-Y

This question in 9618/23 May/June 2023