TopicalComputer Science 9618Software DevelopmentProgram Testing and MaintenancePaper 2

Program Testing and Maintenance — Paper 2 · A Level Computer Science 9618

12.3· 19 questions · 172 marks · 206 min · 2021–2023· Structured questions

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

Different topic or paper

Questions24 pages

Question 1: A procedure, FormatName(): • is called with a string containing words and spaces as its parameter. In this context, a word is any sequence …Question 2: Sylvia is testing a program that has been written by her colleague. Her colleague tells her that the program does not contain any syntax er…1 / 24
Question 2 (continued)2 / 24
Question 3: A program controls the heating system in a sports hall. Part of the program involves reading a value from a sensor. The sensor produces a n…3 / 24
Question 4: Sylvia is testing a program that has been written by her colleague. Her colleague tells her that the program does not contain any syntax er…4 / 24
Question 4 (continued)Question 5: A program controls the heating system in a sports hall. Part of the program involves reading a value from a sensor. The sensor produces a n…5 / 24
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…6 / 24
Question 7: Study the following pseudocode. Line numbers are for reference only. 10 PROCEDURE Encode() 11 DECLARE CountA, CountB, ThisNum : INTEGER 12 …7 / 24
Question 7 (continued)8 / 24
Question 8: A programming language has string functions equivalent to those given in the insert. The language includes a LEFT() and a RIGHT() function,…9 / 24
Question 9: A program has been written to implement a website browser and maintenance is now required. One type of maintenance is called perfective. Na…Question 10: Items in a factory are weighed automatically. The weight is stored as an integer value representing the item weight to the nearest gram (g)…10 / 24
Question 11: (a) A programmer is developing an algorithm to solve a problem. Part of the algorithm would be appropriate to implement as a subroutine (a …11 / 24
Question 11 (continued)Question 12: (a) The factorial of an integer number is the product of all the integers from that number down to 1. In general, the factorial of n is n ×…12 / 24
Question 12 (continued)13 / 24
Question 12 (continued)14 / 24
Question 13: A program is required for a shopping website. (a) Part of the program requires four variables. The following table describes the use of eac…15 / 24
Question 13 (continued)Question 14: (a) A text string contains three data items concatenated as shown: <StockID><Description><Cost> Item lengths are: Item Length StockID 5 Des…16 / 24
Question 14 (continued)17 / 24
Question 14 (continued)Question 15: Components are weighed during manufacture. Weights are measured to the nearest whole gram. Components that weigh at least 3 grams more than…18 / 24
Question 15 (continued)19 / 24
Question 16: A programmer has written a program which includes the function Calculate(). When the program is run, the function returns an unexpected val…20 / 24
Question 16 (continued)21 / 24
Question 17: Several companies are developing websites to market a new type of games console. The company that is first to create a website that can dem…22 / 24
Question 18: A programmer has produced the following pseudocode to output the square root of the numbers from 1 to 10. Line numbers are for reference on…23 / 24
Question 18 (continued)Question 19: A program is designed, coded and compiled without errors. The compiled code is sent for testing. (a) The program will be tested using the w…24 / 24

Mark scheme19 answers

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

Pastlit

Computer Science 9618 · Program Testing and Maintenance — Paper 2

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

Question

Answer

Marks

1Mark scheme for question 15
2Mark scheme for question 214
3Mark scheme for question 37
4Mark scheme for question 414
5Mark scheme for question 57
6Mark scheme for question 611
7Mark scheme for question 710
8Mark scheme for question 86
9Mark scheme for question 94
10Mark scheme for question 104
11Mark scheme for question 1111
12Mark scheme for question 1211
13Mark scheme for question 1312
14Mark scheme for question 1417
15Mark scheme for question 1511
16Mark scheme for question 1610
17Mark scheme for question 176
18Mark scheme for question 188
19Mark scheme for question 194
QuestionAnswerMarksFrom
1see sheet59618/22 May/June 2021
2see sheet149618/21 Oct/Nov 2021
3see sheet79618/21 Oct/Nov 2021
4see sheet149618/23 Oct/Nov 2021
5see sheet79618/23 Oct/Nov 2021
6see sheet119618/22 May/June 2022
7see sheet109618/22 May/June 2022
8see sheet69618/22 May/June 2022
9see sheet49618/23 May/June 2022
10see sheet49618/23 May/June 2022
11see sheet119618/22 Oct/Nov 2022
12see sheet119618/22 Oct/Nov 2022
13see sheet129618/23 Oct/Nov 2022
14see sheet179618/23 Oct/Nov 2022
15see sheet119618/23 Oct/Nov 2022
16see sheet109618/21 May/June 2023
17see sheet69618/21 May/June 2023
18see sheet89618/22 May/June 2023
19see sheet49618/23 May/June 2023

Another paper, or another topic

All of Software Development

Questions as text

Q1 · A procedure, FormatName(): • is called with a string containing words and spaces as its… 9618/22 May/June 2021

7 A procedure, FormatName(): • is called with a string containing words and spaces as its parameter. In this context, a word is any sequence of characters that does not contain a space character. • creates a new formatted string from this string with the following requirements: 1. Any leading spaces removed (spaces before the first word). 2. Any trailing spaces removed (spaces after the last word). 3. Any multiple spaces between words converted to a single space. 4. All characters converted to lower case. The FormatName() procedure has been written in a programming language and is to be tested using the black-box method. (a) Give a test string that could be used to show that all four formatting requirements have been applied correctly. Use the symbol ‘∇’ to represent a space character. … [3] (b) The FormatName() procedure should assign a value to the global variable FString. There is a fault in the program, which means that the assignment does not always take place. Explain two ways of exposing the fault. … … … … … [2]

5 marks

Mark scheme: 7(a) Test string should contain: 3 • At least one leading space (before the first word) • at least one trailing space (after the last word) • at least one instance of multiple spaces between words • At least one upper case character Mark as follows: One mark for one correct Two marks for three correct Three marks for all correct 7(b) One mark for each: 2 • Dry run / produce a trace table / walk through the code • Add output statements to allow the code to be tracked • Insert a Breakpoint into the program // use single-stepping to execute instructions // monitor variables using a watch window • Try different test values to see which ones fail Note: Max 2 marks

This question in 9618/22 May/June 2021

Q2 · Sylvia is testing a program that has been written by her colleague 9618/21 Oct/Nov 2021

1 Sylvia is testing a program that has been written by her colleague. Her colleague tells her that the program does not contain any syntax errors. (a) (i) State what her colleague means by “does not contain any syntax errors”. … … … [1] (ii) Identify and describe one other type of error that the program may contain. Type of error … Description … … [2] (b) Complete the following table by giving the appropriate data type in each case. Use of variable Data type The average mark in a class of 40 students An email address The number of students in the class To indicate whether an email has been read [4] (c) An airline wants to provide passengers with information about individual flights and allow them to book their flight using an online booking system. (i) Tick (3) one box in each row of the table to indicate whether each item of information would be essential for the customer when making the booking. Information Essential Not essential Departure time Flight number Departure airport Aircraft type Ticket price Number of seats in aircraft [3] (ii) Identify the technique used to filter out information that is not essential when designing the booking system and state one benefit of this technique. Technique … Benefit … … [2] (iii) Identify two additional pieces of essential information that a passenger might need when booking a flight. 1 … 2 … [2]

14 marks

Mark scheme: Question Answer Marks 1(a)(i) One from: 1 • The program obeys the rules / grammar of the programming language used • The program will run // it can be compiled / interpreted • Accept by example. e.g. 'no mis-spelt keywords' / 'all brackets match' 1(a)(ii) One mark for type plus one for corresponding description 2 Type of error: A logic error Description: • An error in the algorithm / design of the solution • the program does not behave as expected / give the expected output. • Accept by example e.g. wrong arithmetic operator used / wrong loop count OR Type of error: Run-time error Description: • The program performs an illegal instruction / invalid operation • Accept by example: divide by zero or endless loop or simply 'crashes' / freezes 1(b) 4 Use of variable Data type The average mark in a class of 40 students REAL An email address STRING The number of students in the class INTEGER Indicate whether an email has been read BOOLEAN One mark per row 1(c)(i) 3 Information Essential Not essential Departure time  Flight Number  Departure airport  Aircraft type  Ticket price  Number of seats in aircraft  One mark for two rows correct Two mark for four rows correct Three mark for all rows correct 1(c)(ii) One mark for technique and one for benefit, Max 1 mark for 'Benefit' 2 Technique: Abstraction Benefit: • The solution is simplified so easier / quicker to design / implement • The system is tailored to the need of the user 1(c)(iii) Answers include: 2 • Destination / arrival airport • Arrival time / flight duration • Date of flight • Seat number • Seat availability Max 2 marks

This question in 9618/21 Oct/Nov 2021

Q3 · A program controls the heating system in a sports hall 9618/21 Oct/Nov 2021

4 A program controls the heating system in a sports hall. Part of the program involves reading a value from a sensor. The sensor produces a numeric value that represents the temperature. The value is an integer, which should be in the range 0 to 40 inclusive. A program function has been written to validate the values from the sensor. (a) A test plan is needed to test the function. Complete the table. The first line has been completed for you. You can assume that the sensor will generate only integer data values. Test Test data value Explanation Expected outcome 1 23 Normal data Data is accepted 2 3 4 5 [4] (b) A program module controls the heaters. This module operates as follows: • If the temperature is below 10, switch the heaters on. • If the temperature is above 20, switch the heaters off. Complete the following state-transition diagram for the heating system: Start Heaters Heaters Off On [3]

7 marks

Mark scheme: 4(a) 4 Test Test data value Explanation Expected Outcome 1 23 Normal Data Data is accepted 2 0 Boundary Data Data is accepted 3 40 Boundary Data Data is accepted 4 >= 41 Abnormal Data Data is rejected 5 <= −1 Abnormal Data Data is rejected One mark per row for rows 2 to 5. 4(b) 3 One mark for each label: • Temp < 10 (Heaters Off to Heaters On) • Temp > 20 (Heaters On to Heaters Off) • on BOTH loops (non-contradictory values)

This question in 9618/21 Oct/Nov 2021

Q4 · Sylvia is testing a program that has been written by her colleague 9618/23 Oct/Nov 2021

1 Sylvia is testing a program that has been written by her colleague. Her colleague tells her that the program does not contain any syntax errors. (a) (i) State what her colleague means by “does not contain any syntax errors”. … … … [1] (ii) Identify and describe one other type of error that the program may contain. Type of error … Description … … [2] (b) Complete the following table by giving the appropriate data type in each case. Use of variable Data type The average mark in a class of 40 students An email address The number of students in the class To indicate whether an email has been read [4] (c) An airline wants to provide passengers with information about individual flights and allow them to book their flight using an online booking system. (i) Tick (3) one box in each row of the table to indicate whether each item of information would be essential for the customer when making the booking. Information Essential Not essential Departure time Flight number Departure airport Aircraft type Ticket price Number of seats in aircraft [3] (ii) Identify the technique used to filter out information that is not essential when designing the booking system and state one benefit of this technique. Technique … Benefit … … [2] (iii) Identify two additional pieces of essential information that a passenger might need when booking a flight. 1 … 2 … [2]

14 marks

Mark scheme: Question Answer Marks 1(a)(i) One from: 1 • The program obeys the rules / grammar of the programming language used • The program will run // it can be compiled / interpreted • Accept by example. e.g. 'no mis-spelt keywords' / 'all brackets match' 1(a)(ii) One mark for type plus one for corresponding description 2 Type of error: A logic error Description: • An error in the algorithm / design of the solution • the program does not behave as expected / give the expected output. • Accept by example e.g. wrong arithmetic operator used / wrong loop count OR Type of error: Run-time error Description: • The program performs an illegal instruction / invalid operation • Accept by example: divide by zero or endless loop or simply 'crashes' / freezes 1(b) 4 Use of variable Data type The average mark in a class of 40 students REAL An email address STRING The number of students in the class INTEGER Indicate whether an email has been read BOOLEAN One mark per row 1(c)(i) 3 Information Essential Not essential Departure time  Flight Number  Departure airport  Aircraft type  Ticket price  Number of seats in aircraft  One mark for two rows correct Two mark for four rows correct Three mark for all rows correct 1(c)(ii) One mark for technique and one for benefit, Max 1 mark for 'Benefit' 2 Technique: Abstraction Benefit: • The solution is simplified so easier / quicker to design / implement • The system is tailored to the need of the user 1(c)(iii) Answers include: 2 • Destination / arrival airport • Arrival time / flight duration • Date of flight • Seat number • Seat availability Max 2 marks

This question in 9618/23 Oct/Nov 2021

Q5 · A program controls the heating system in a sports hall 9618/23 Oct/Nov 2021

4 A program controls the heating system in a sports hall. Part of the program involves reading a value from a sensor. The sensor produces a numeric value that represents the temperature. The value is an integer, which should be in the range 0 to 40 inclusive. A program function has been written to validate the values from the sensor. (a) A test plan is needed to test the function. Complete the table. The first line has been completed for you. You can assume that the sensor will generate only integer data values. Test Test data value Explanation Expected outcome 1 23 Normal data Data is accepted 2 3 4 5 [4] (b) A program module controls the heaters. This module operates as follows: • If the temperature is below 10, switch the heaters on. • If the temperature is above 20, switch the heaters off. Complete the following state-transition diagram for the heating system: Start Heaters Heaters Off On [3]

7 marks

Mark scheme: 4(a) 4 Test Test data value Explanation Expected Outcome 1 23 Normal Data Data is accepted 2 0 Boundary Data Data is accepted 3 40 Boundary Data Data is accepted 4 >= 41 Abnormal Data Data is rejected 5 <= −1 Abnormal Data Data is rejected One mark per row for rows 2 to 5. 4(b) 3 One mark for each label: • Temp < 10 (Heaters Off to Heaters On) • Temp > 20 (Heaters On to Heaters Off) • on BOTH loops (non-contradictory values)

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 · Study the following pseudocode 9618/22 May/June 2022

5 Study the following pseudocode. Line numbers are for reference only. 10 PROCEDURE Encode() 11 DECLARE CountA, CountB, ThisNum : INTEGER 12 DECLARE ThisChar : CHAR 13 DECLARE Flag : BOOLEAN 14 CountA 0 15 CountB 10 16 Flag TRUE 17 INPUT ThisNum 18 WHILE ThisNum <> 0 19 ThisChar LEFT(NUM_TO_STR(ThisNum), 1) 20 IF Flag = TRUE THEN 21 CASE OF ThisChar 22 '1' : CountA CountA + 1 23 '2' : IF CountB < 10 THEN 24 CountA CountA + 1 25 ENDIF 26 '3' : CountB CountB - 1 27 '4' : CountB CountB - 1 28 Flag FALSE 29 OTHERWISE : OUTPUT "Ignored" 30 ENDCASE 31 ELSE 32 IF CountA > 2 THEN 33 Flag NOT Flag 34 OUTPUT "Flip" 35 ELSE 36 CountA 4 37 ENDIF 38 ENDIF 39 INPUT ThisNum 40 ENDWHILE 41 OUTPUT CountA 42 ENDPROCEDURE (a) Procedure Encode() contains a loop structure. Identify the type of loop and state the condition that ends the loop. Do not include pseudocode statements in your answer. Type … Condition … … [2] (b) Complete the trace table below by dry running the procedure Encode() when the following values are input: 12, 24, 57, 43, 56, 22, 31, 32, 47, 99, 0 The first row is already complete. ThisNum ThisChar CountA CountB Flag OUTPUT 0 10 TRUE [6] (c) Procedure Encode() is part of a modular program. Integration testing is to be carried out on the program. Describe integration testing. … … … … [2]

10 marks

Mark scheme: 5(a) One mark for type and one mark for condition: 2 Independent marks Type: pre-condition Condition: when the value of ThisNum / the input value is equal to zero 5(b) 6 ThisNum ThisChar CountA CountB Flag OUTPUT 0 10 TRUE 12 '1' 1 24 '2' 57 '5' "Ignored" 43 '4' 9 FALSE '5' 56 4 22 '2' TRUE "Flip" '3' 31 8 32 '3' 7 47 '4' 6 FALSE 99 '9' TRUE "Flip" 0 4 Marks as follows: One mark per outlined group If no marks per group then mark by columns (columns 3 to 6) for max 4 5(c) One mark per point: 2  Modules that have already been tested individually  are combined into a single (sub) program which is then tested as a whole

This question in 9618/22 May/June 2022

Q8 · A programming language has string functions equivalent to those given in the insert 9618/22 May/June 2022

7 A programming language has string functions equivalent to those given in the insert. The language includes a LEFT() and a RIGHT() function, but it does not have a MID() function. (a) Write pseudocode for an algorithm to implement your own version of the MID() function which will operate in the same way as that shown in the insert. Do not use the MID() function given in the insert, but you may use any of the other functions. Assume that the values passed to the function will be correct. … … … … … … … … … … [4] (b) The values passed to your MID() function in part (a) need to be validated. Assume that the values are of the correct data type. State two checks that could be applied to the values passed to the function. 1 … … 2 … … [2]

6 marks

Mark scheme: 7(a) FUNCTION MID(InString : STRING, Start, Num : INTEGER) 4 RETURNS STRING DECLARE MidString : STRING DECLARE InStringLen : INTEGER InStringLen  LENGTH(InString) // solution for RIGHT() then LEFT() MidString  RIGHT(InString, InStringLen – Start + 1) MidString  LEFT(MidString, Num) // alternative solution for LEFT() then RIGHT() MidString  LEFT(InString, Start + Num - 1) MidString  RIGHT(MidString, Num) RETURN MidString ENDFUNCTION Marks as follows: 1 Function heading and ending including parameters and return type 2 Correct use of one substring functions 3 Correct use of both substring functions (in correct sequence) 4 Return substring after a reasonable attempt 7(b) One mark per point 2 Check that:  Start and/or Num are >= 1 // positive  Length of InString is "sufficient" for required operation

This question in 9618/22 May/June 2022

Q9 · A program has been written to implement a website browser and maintenance is now required 9618/23 May/June 2022

2 A program has been written to implement a website browser and maintenance is now required. One type of maintenance is called perfective. Name two other types of maintenance that the program may require and give a reason for each. Type 1 … Reason … … … … Type 2 … Reason … … … … [4]

4 marks

Mark scheme: 2 Dependent marks 4 One mark for type; one mark for matching reason Answers include: Type: Adaptive Reason: To accommodate a change in the requirement / technology / legislation e.g. a new HTML version is available Type: Corrective Reason: The program does not operate as expected / contains a bug e.g. passwords are not hidden

This question in 9618/23 May/June 2022

Q10 · Items in a factory are weighed automatically 9618/23 May/June 2022

4 Items in a factory are weighed automatically. The weight is stored as an integer value representing the item weight to the nearest gram (g). A function is written to validate the weight of each item. The function will return "PASS" if the weight of the item is within the acceptable range, otherwise the function will return "FAIL". The acceptable weight range for an item is 150 g to 155 g inclusive. The validation function is to be properly tested. Black-box testing will be used and a test plan needs to be produced. Complete the table by writing additional tests to test this function. Type of Example Expected Explanation test data test value return value Normal 153 "PASS" Value within the acceptable range [4]

4 marks

Mark scheme: 4 One mark per row 2 to 7 to Max 4 4 Type of Example Expected Explanation test data test value return value Value within the acceptable Normal 153 "PASS" range Outside acceptable range / Abnormal < 149 "FAIL" too small Abnormal / 149 "FAIL" Maximum unacceptable Boundary Boundary / Extreme / 150 "PASS" Minimum acceptable Normal Boundary / Extreme / 155 "PASS" Maximum acceptable Normal Abnormal / 156 "FAIL" Minimum unacceptable Boundary Outside acceptable range / Abnormal >156 "FAIL" too large

This question in 9618/23 May/June 2022

Q11 · A programmer is developing an algorithm to solve a problem 9618/22 Oct/Nov 2022

1 (a) A programmer is developing an algorithm to solve a problem. Part of the algorithm would be appropriate to implement as a subroutine (a procedure or a function). (i) State two reasons why the programmer may decide to use a subroutine. 1 … … 2 … … [2] (ii) A procedure header is shown in pseudocode: PROCEDURE MyProc(Count : INTEGER, Message : STRING) Give the correct term for the identifiers Count and Message and explain their use. Term … Use … … … … [2] (b) The algorithm in part (a) is part of a program that will be sold to the public. All the software errors that were identified during in-house testing have been corrected. Identify and describe the additional test stage that may be carried out before the program is sold to the public. Test stage … Description … … … … … … [4] (c) Part of an identifier table is shown: Variable Type Example value FlagDay DATE 23/04/2004 CharList STRING "ABCDEF" Count INTEGER 29 Complete the table by evaluating each expression using the example values. Expression Evaluation MID(CharList, MONTH(FlagDay), 1) INT(Count / LENGTH(CharList)) (Count >= 29) AND (DAY(FlagDay) > 23) [3]

11 marks

Mark scheme: Question Answer Marks 1(a)(i) One mark for each point (Max 2): 2 • When a task which is repeated / reused / performed in several places • When a part of an algorithm performs a specific task • Reduces complexity of program / program is simplified // subroutine already available • Testing / debugging / maintenance is easier 1(a)(ii) One mark for each part: 2 Term: Parameter(s) Use: to pass values / arguments to the procedure 1(b) One mark for test stage, one mark for each description point 4 (Max 3 for Description) Test stage: Beta testing Description: 1 Testing carried out by a small group of (potential) users 2 Users will check that the software works as required / works in the real world / does not contain errors 3 Users will feedback problems / suggestions for improvement 4 Problems / suggestions identified are addressed (before the program is sold) 1(c) One mark per row: 3 Expression Evaluation MID(CharList, MONTH(FlagDay), 1) 'D' INT(Count / LENGTH(CharList)) 4 (Count >= 99) AND (DAY(FlagDay) > 23) FALSE

This question in 9618/22 Oct/Nov 2022

Q12 · The factorial of an integer number is the product of all the integers from that number… 9618/22 Oct/Nov 2022

6 (a) The factorial of an integer number is the product of all the integers from that number down to 1. In general, the factorial of n is n × (n−1) × ... × 2 × 1 For example, the factorial of 5 is 5 × 4 × 3 × 2 × 1 = 120 In this question, n will be referred to as the BaseNumber. A function FindBaseNumber() will: • be called with a positive, non-zero integer value as a parameter • return BaseNumber if the parameter value is the factorial of the BaseNumber • return −1 if the parameter value is not a factorial. For example: Parameter value Value returned 120 5 12 −1 6 3 1 1 FindBaseNumber(12) will return −1 because 12 is not a factorial. You may use the rest of this page for rough working. Write pseudocode for the function FindBaseNumber(). … … … … … … … … … … … … … … … … … … … … … … … … … [7] (b) A program is written to allow a user to input a sequence of values to be checked using the function FindBaseNumber(). The user will input one value at a time. The variable used to store the user input has to be of type string because the user will input ‘End’ to end the program. Valid input will be converted to an integer and passed to FindBaseNumber() and the return value will be output. Complete the table by giving four invalid strings that may be used to test distinct aspects of the required validation. Give the reason for your choice in each case. Input Reason for choice … … … … … … … … … … … … [4]

11 marks

Mark scheme: 6(a) Example by repeated multiplication: 7 Mark as follows (multiplication solution), (Max 7): 1 Function heading and ending including parameter and return type 2 Declaration and initialisation of local Num 3 Any conditional loop 4 Conditional loop until ThisValue found or Try out of range 5 Multiply Try by Num in a loop 6 Compare Try with ThisValue and set termination if the same in a loop 7 Increment Num and repeat in a loop 8 Attempt to Return Num if ThisValue is a factorial or -1 otherwise FUNCTION FindBaseNumber(ThisValue : INTEGER) RETURNS INTEGER DECLARE Num, Try : INTEGER DECLARE Found : BOOLEAN Num  0 Found  FALSE Try  1 WHILE Try <= ThisValue AND Found = FALSE Num  Num + 1 Try  Try * Num IF Try = ThisValue THEN //BaseNumber found Found  TRUE ENDIF ENDWHILE IF Found = TRUE THEN RETURN Num ELSE RETURN -1 ENDIF ENDFUNCTION 6(a) Alternative FOR LOOP solution. Mark as follows: 1 Function heading and ending including parameter and return type 2 Declaration of local Integer value for Num and Try 3 Count-controlled Loop from 1 to ThisValue 4 Multiply Try by Num in a loop 5 Compare Try with ThisValue in a loop 6 ...Immediate return of Num if they are the same in a loop 7 Return –1 if ThisValue not found after loop FUNCTION FindBaseNumber(ThisValue : INTEGER) RETURNS INTEGER DECLARE Num, Try : INTEGER Try  1 FOR Num  1 TO ThisValue Try  Try * Num IF Try = ThisValue THEN //BaseNumber found RETURN Num ENDIF NEXT Num RETURN -1 ENDFUNCTION 6(b) One mark per row. 4 Examples of invalid strings: 1 Non-numeric but not "End" // contains space or other non-numeric characters 2 Real number 3 Integer value out of range (i.e. <= 0) 4 Empty string 5 Correct word but wrong case e.g. "end" rather than "End" Input Reason for choice "Aardvark" Non-numeric (and not "End") "27.3" Numeric but not an integer "-3" // "0" A non-positive integer "" An empty string

This question in 9618/22 Oct/Nov 2022

Q13 · A program is required for a shopping website 9618/23 Oct/Nov 2022

1 A program is required for a shopping website. (a) Part of the program requires four variables. The following table describes the use of each variable. Complete the table by adding the most appropriate data type for each variable. Variable use Data type Store the number of days in the current month Store the first letter of the customer’s first name Store an indication of whether a year is a leap year Store the average amount spent per customer visit [4] (b) The designer considers the use of a development life cycle to split the development of the website into several stages. (i) State one benefit of a development life cycle when developing the website. … … [1] (ii) Analysis is one stage of a development life cycle. State one document that may be produced from the analysis stage of the website project. … … [1] (c) The program will be developed using the Rapid Application Development (RAD) life cycle. (i) State one principle of this life cycle. … … [1] (ii) Give two benefits and one drawback of its use compared to the waterfall life cycle. Benefit 1 … … Benefit 2 … … Drawback … … [3] (d) Adaptive maintenance needs to be carried out on the website program. Give two reasons why adaptive maintenance may be required. 1 … … 2 … … [2]

12 marks

Mark scheme: Question Answer Marks 1(a) One mark per row 4 Variable use Data type Store the number of days in the current month INTEGER Store the first letter of the customer's first name CHAR Store an indication of whether a year is a leap BOOLEAN year Store the average amount spent per customer REAL visit 1(b)(i) Easier to manage/plan/cost // Clear deliverables produced at (end of) each 1 stage 1(b)(ii) One mark per point (Max 1): 1 • The problem definition • Requirements specification // Client requirements • Documentation related to current system (e.g. ER diagram of current system, DFD of current system, feasibility study) 1(c)(i) One mark per point (Max 1): 1 • Modules are developed in parallel / as prototypes • Minimal / no detailed planning is carried out // Allows for changes to requirements • Flexible development process • Small incremental releases are made, each adding functionality • Used for time critical development • Client involved during (all stages) of development 1(c)(ii) Examples include: 3 Benefits: (Max 2 marks) • Quicker development possible / Multiple areas can be worked on at same time • Prototype produced (at early stage in process) • Easier to change requirements / quicker delivery of usable modules • Early review possible / closer cooperation between client and developers Drawback: (Max 1 mark) • Difficult to estimate cost / time to complete project • Documentation often omitted • Lack of client availability throughout life cycle // too easy for client to keep changing their mind 1(d) One mark for each point (Max 2) 2 Examples include: 1 Change to website requirements 2 New technologies available to host website // changes made to library modules used 3 Change in relevant legislation

This question in 9618/23 Oct/Nov 2022

Q14 · A text string contains three data items concatenated as shown… 9618/23 Oct/Nov 2022

5 (a) A text string contains three data items concatenated as shown: <StockID><Description><Cost> Item lengths are: Item Length StockID 5 Description 32 Cost the remainder of the string A procedure Unpack() takes four parameters of type string. One parameter is the original text string. The other three parameters are used to represent the three data items shown in the table and are assigned values within the procedure. These values will be used by the calling program after the procedure ends. (i) Write pseudocode for the procedure Unpack(). … … … … … … … … … … [6] (ii) Explain the term procedure interface with reference to procedure Unpack(). … … … … [2] (b) The design changes and a record structure is defined to store the three data items. A user-defined data type StockItem is created as shown: TYPE StockItem DECLARE StockID : STRING DECLARE Description : STRING DECLARE Cost : REAL ENDTYPE (i) A variable LineData of type StockItem is declared. Write the pseudocode statement to assign the value 12.99 to the Cost field of LineData. … [1] (ii) Procedure Unpack() is modified and converted to a function which takes the original text string as the only parameter. Explain the other changes that need to be made to convert the procedure into a function. … … … … … [2] (c) Unpack() is part of a program made up of several modules. During the design stage, it is important to follow good programming practice. One example of good practice is the use of meaningful identifier names. Give the reason why this is good practice. Give two other examples of good practice. Reason … … … Example 1 … … … Example 2 … … … [3] (d) The program that includes Unpack() is tested using the walkthrough method. Describe this method and explain how it can be used to identify an error. … … … … … … [3]

17 marks

Mark scheme: 5(a)(i) One mark per point: 6 1 Procedure heading and ending including four parameters... 2 ...and use of BYREF for the three extracted values 3 Extract and assign SID 4 Extract and assign SDesc 5 Calculation of length of SCost (remainder of string) 6 Extract and assign SCost following an attempt at MP5 PROCEDURE UnPack(BYVAL TLine : STRING, BYREF SID, SDesc, SCost : STRING) SID  LEFT(TLine, 5) SDesc  MID(TLine, 6, 32) SCost  RIGHT(TLine, LENGTH(TLine) – 37) ENDPROCEDURE 5(a)(ii) One mark each (Max 2): 2 1 Provides a mechanism to allow calling program to pass data 2 Defines the four parameters of Unpack() 3 … giving their data type and order 5(b)(i) LineData.Cost  12.99 1 5(b)(ii) One mark per point (Max 2): 2 • The new function will return an item of type StockItem • Need to declare/use a (local) variable of type StockItem • Costfield needs to be converted from a string to a real 5(c) One mark for reason 3 One mark for each example (Max 2) Reason: • Makes the code easier to understand // Describes the purpose of the identifier // Makes the code easier to debug/test/maintain Further examples include: • White space • Indentation • Keywords in capitals • Comments • Local variables // parameters 5(d) One mark per point (Max 3) 3 1 The program is checked by creating a trace table / going through the program a line at a time 2 ….to record/check variable (values) as they change 3 Error may be indicated when variable given an unexpected value 4 Error may be indicated by an unexpected path through the program // Faults in the logic of the program can be detected

This question in 9618/23 Oct/Nov 2022

Q15 · Components are weighed during manufacture 9618/23 Oct/Nov 2022

6 Components are weighed during manufacture. Weights are measured to the nearest whole gram. Components that weigh at least 3 grams more than the maximum weight, or at least 3 grams less than the minimum weight, are rejected. A component is rechecked if it weighs within 2 grams of either the maximum or minimum weight. The final outcome of weighing each component is shown below: Outcome Weight Reject Max + 2 Recheck Max Maximum weight Max – 2 Accept Min + 2 Recheck Min Minimum weight Min – 2 Reject A function Status() will be called with three parameters. These are integers representing the weight of an individual component together with the minimum and maximum weights. The value returned from the function will be as follows: Outcome Return value Accept 'A' Reject 'R' Recheck 'C' (a) Complete the following test plan for five tests that could be performed on function Status(). The tests should address all possible outcomes. Test number Component weight Min Max Expected return value 1 'A' 2 3 4 5 [5] (b) Write pseudocode for Status(). … … … … … … … … … … … … … … … … … … … … [6]

11 marks

Mark scheme: 6(a) One mark per row 5 Examples: Test Component Expected return Min Max number weight value 1 300 290 315 'A' 2 > 317 290 315 'R' 3 317 290 315 'C' 4 288 290 315 'C' 5 < 288 290 315 'R' 6(b) One mark per point: 6 1 Function heading and ending including parameters 2 Declaration of local variable for Result / alt mechanism 3 Check for Reject 4 Check for Accept 5 Check for Recheck (or just default to third option) 6 Return Result following a reasonable attempt Function Status(Actual, Min, Max : INTEGER) RETURNS CHAR DECLARE Result : CHAR CONSTANT Accept = 'A' CONSTANT Reject = 'R' CONSTANT ReCheck = 'C' Result  ReCheck //Check if reject IF Actual > Max + 2 OR Actual < Min – 2 THEN Result  Reject ENDIF //Check if acceptable IF Actual < Max - 2 AND Actual > Min + 2 THEN Result  Accept ENDIF RETURN Result ENDFUNCTION

This question in 9618/23 Oct/Nov 2022

Q16 · A programmer has written a program which includes the function Calculate() 9618/21 May/June 2023

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]

10 marks

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

This question in 9618/21 May/June 2023

Q17 · Several companies are developing websites to market a new type of games console 9618/21 May/June 2023

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]

6 marks

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)

This question in 9618/21 May/June 2023

Q18 · A programmer has produced the following pseudocode to output the square root of the… 9618/22 May/June 2023

5 A programmer has produced the following pseudocode to output the square root of the numbers from 1 to 10. Line numbers are for reference only. 10 DECLARE Num : REAL 11 Num 1.0 ... 40 REPEAT 41 CALL DisplaySqrt(Num) 42 Num Num + 1.0 43 UNTIL Num > 10 ... 50 PROCEDURE DisplaySqrt(BYREF ThisNum : REAL) 51 OUTPUT ThisNum 52 ThisNum SQRT(ThisNum) // SQRT returns the square root 53 OUTPUT " has a square root of ", ThisNum 54 ENDPROCEDURE The pseudocode is correctly converted into program code. Function SQRT() is a library function and contains no errors. The program code compiles without errors, but the program gives unexpected results. These are caused by a design error. (a) Explain why the program gives unexpected results. … … … … … … [3] (b) Explain why the compiler does not identify this error. … … [1] (c) Describe how a typical Integrated Development Environment (IDE) could be used to identify this error. … … … … … … [3] (d) The pseudocode is converted into program code as part of a larger program. During compilation, a complex statement generates an error. The programmer does not want to delete the complex statement but wants to change the statement so that it is ignored by the compiler. State how this may be achieved. … … [1]

8 marks

Mark scheme: 5(a) One mark per point: 3  parameter / Num has been passed by reference // should have been passed by value  so when the value / ThisNum is modified (in procedure DisplaySqrt())  the new value will be used in the loop (lines 40–43) // Num will be changed to modified value 5(b)  The rules of the language have not been broken // there are no syntax 1 errors 5(c) Could use an IDE to: 3  Set a breakpoint to stop the program at a certain line / statement / point  Step through the program line by line / statement by statement  checking the value of 'num' / a variable using a report / watch window One mark per bullet 5(d) Answers include: 1  Change the statement into a comment  Change the statement to a string representing a literal value and assign it to a variable / output it Note: max 1 mark

This question in 9618/22 May/June 2023

Q19 · A program is designed, coded and compiled without errors 9618/23 May/June 2023

5 A program is designed, coded and compiled without errors. The compiled code is sent for testing. (a) The program will be tested using the walkthrough method. Additional information will be needed before this method can be used. Identify this additional information and explain why it is needed. Additional information … … Explanation … … … … [3] (b) Testing is completed and the program is made available to users. Some time later, changes are made to the program to improve the speed of response. State the type of maintenance that has been applied to the program. … [1]

4 marks

Mark scheme: 5(a) Max 3 marks 3 Additional Information: MP1 The (program/source) code/specification MP2 test plan // inputs/test data and expected outputs Explanation: MP3 The structure / design / algorithm of the program of the program needs to be known MP4 …. so that all paths through the program can be tested 5(b) Perfective 1

This question in 9618/23 May/June 2023