Skip to content

10.1 Data Types & Records

AS Level · 28 questions found

  • Select appropriate data types: INTEGER, REAL, CHAR, STRING, BOOLEAN, DATE
  • Purpose of a record: holds mixed data types under one identifier
  • Write pseudocode to define, read from and write to a record structure
Q1
Oct/Nov 2025 Paper 2 v1

A program is being developed to meet a particular customer requirement.

(a) The program contains these variables: 4 marks

Variable Data type
MyChar CHAR
MyString STRING
MyInt INTEGER
MyDOB DATE

Complete the table by filling in the gaps using functions and/or operators from the insert.

Each expression must be valid.

(b) Different test methods will be used at different stages of the program development. 3 marks

Complete the table by identifying the test method that matches the test description.

The first row has been completed for you.

Test description Test method
carried out as soon as a program module has been coded alpha
carried out as program modules are being combined
completed by the developers without referring to the code
completed by the customer

(c) During the alpha testing stage, an Integrated Development Environment (IDE) is used to help locate an error that has been identified. The IDE report window feature is used to examine the values assigned to variables. 3 marks

Explain how two other IDE features are used together with the report window feature to help locate the error.

A program is being developed to meet a particular customer requirement. ### (a) The program contains these variables: <span class="part-marks">4 marks</span> |Variable|Data type| |---|---| |MyChar|CHAR| |MyString|STRING| |MyInt|INTEGER| |MyDOB|DATE| Complete the table by filling in the gaps using functions and/or operators from the insert. Each expression must be valid. ### (b) Different test methods will be used at different stages of the program development. <span class="part-marks">3 marks</span> Complete the table by identifying the test method that matches the test description. The first row has been completed for you. |Test description|Test method| |---|---| |carried out as soon as a program module has been coded|alpha| |carried out as program modules are being combined|| |completed by the developers without referring to the code|| |completed by the customer|| ![](../images/w25_21_q1_fig1.png) ### (c) During the alpha testing stage, an Integrated Development Environment (IDE) is used to help locate an error that has been identified. The IDE report window feature is used to examine the values assigned to variables. <span class="part-marks">3 marks</span> Explain how two other IDE features are used together with the report window feature to help locate the error.
Show mark scheme

1(a) [4 marks]

Expression  & MyString 'X' MyString  MID 1 / 2 / 3 / 4 , 1 MyChar ("ABCD", )  NUM_TO_STR ( DAY / MONTH / YEAR / DAYINDEX MyString (MyDOB))  INT LENGTH MyInt ( (MyString) / 2) One mark per row

1(b) [3 marks]

Test description Test method carried out as soon as a program module has been alpha coded carried out as program modules are being integration combined completed by the developers without referring to black-box the code completed by the customer acceptance / beta One mark per row (2 to 4)

1(c) [3 marks]

One mark per point: 1 reference to a breakpoint 2 reference to single stepping 3 Correct explanation of both e.g. to stop program execution at specific point / line / statement / instruction and to execute one line / statement / instruction at a time to (locate an/the error) One mark for each bulleted point

Q3
Oct/Nov 2025 Paper 2 v1

A program is needed to manage individual rentals in a car-hire business.

The data items for each rental will be held in a record structure of type RentalRecord The programmer has started to define the items that will be needed:

Item Example value Comment
RentalID "AB1234" a unique alpha-numeric value
CarID 241 a numeric value used as an array index
DisCode 'S' a letter indicating the type of discount offered
Start 13/06/2025 when the rental starts
Duration 7 the number of days of the rental
Completed FALSE TRUE when the car is returned and the rental charge paid

(a) (i) Write pseudocode to declare the record structure for type RentalRecord 4 marks

(ii) A 1D array Rental containing 500 elements is used to store the data for all rental records. 2 marks

Write pseudocode to declare the Rental array.

(b) State three benefits of using an array of records to store the data for all rentals. 3 marks

1

2

3

A program is needed to manage individual rentals in a car-hire business. The data items for each rental will be held in a record structure of type RentalRecord The programmer has started to define the items that will be needed: |Item|Example value|Comment| |---|---|---| |RentalID|"AB1234"|a unique alpha-numeric value| |CarID|241|a numeric value used as an array index| |DisCode|'S'|a letter indicating the type of discount offered| |Start|13/06/2025|when the rental starts| |Duration|7|the number of days of the rental| |Completed|FALSE|TRUE when the car is returned and the rental charge paid| ### (a) (i) Write pseudocode to declare the record structure for type RentalRecord <span class="part-marks">4 marks</span> #### (ii) A 1D array Rental containing 500 elements is used to store the data for all rental records. <span class="part-marks">2 marks</span> Write pseudocode to declare the Rental array. ### (b) State three benefits of using an array of records to store the data for all rentals. <span class="part-marks">3 marks</span> 1 2 3
Show mark scheme

3(a)(i) [4 marks]

Pseudocode: TYPE RentalRecord DECLARE RentalID : STRING DECLARE CarID : INTEGER DECLARE DisCode : CHAR DECLARE Start : DATE DECLARE Duration : INTEGER DECLARE Completed : BOOLEAN ENDTYPE Mark as follows: 1 One mark for and statements TYPE RentalRecord ENDTYPE 2 One mark for and declared correctly RentalID CarID 3 One mark for and declared correctly DisCode Start 4 One mark for and declared correctly Duration Completed

3(a)(ii) [2 marks]

DECLARE Rental : ARRAY[1:500] OF RentalRecord One mark per underlined phrase

3(b) [3 marks]

One mark per point: 1 Different data types held (for each rental) under a single identifier 2 Allows for iteration through rentals/records // Can access rentals/records in a loop // Can (directly) access a specific rental/record using an (array) index 3 Simplifies the code/program / less code needed / reduces code duplication // Makes code/program easier to understand // Makes testing / debugging easier // Program maintenance easier

Q8
Oct/Nov 2025 Paper 2 v1

A program is being developed to manage student book loans from a college library. Students may borrow up to five books at a time from the library.

The programmer has defined a record type to define each loan.

The record data items are:

Data item Data type Comment
StudentID STRING the unique ID of the student who has borrowed the book
BookID STRING the unique ID of the book being borrowed
OnLoan BOOLEAN TRUE if the book has not been returned

The programmer has defined a global array Loan to store 5000 loan records.

There are more elements in the array than books in the library. Unused elements have the StudentID set to an empty string. These may occur anywhere in the array.

The programmer has defined the first program module:

Module Description
OKToBorrow()
called with a parameter of type STRING representing a
StudentID

search the array for loan records for the specified student

output a suitable message to say whether the student may, or
may not, borrow another book

(a) Write efficient pseudocode for the module OKToBorrow() 7 marks

(b) A second module is defined: 8 marks

Module Description
ReturnBook()
called with two parameters of type STRING representing a
StudentID and a BookID

searches the array for the relevant loan record

when found, sets OnLoan to FALSE and returns TRUE

if a loan record is not found, or the book has already been
returned, then returns FALSE

Write efficient pseudocode for the module ReturnBook()

Assume that each student is only allowed to borrow each book only once. That means that there will be no more than one loan record for a given combination of student and book.

(c) It is decided to introduce a system of fines for books that have been borrowed for too long. 2 marks

Two new requirements are defined:

  1. Each loan has a maximum length, represented as a number of days.
  2. Each book in the library will be assigned one of three categories. Each category has a different maximum loan length.

Record structure and program design changes are needed to meet these two requirements.

Outline the changes that are necessary to meet the two requirements.

A program is being developed to manage student book loans from a college library. Students may borrow up to five books at a time from the library. The programmer has defined a record type to define each loan. The record data items are: |Data item|Data type|Comment| |---|---|---| |StudentID|STRING|the unique ID of the student who has borrowed the book| |BookID|STRING|the unique ID of the book being borrowed| |OnLoan|BOOLEAN|TRUE if the book has not been returned| The programmer has defined a global array Loan to store 5000 loan records. There are more elements in the array than books in the library. Unused elements have the StudentID set to an empty string. These may occur anywhere in the array. The programmer has defined the first program module: |Module|Description| |---|---| |OKToBorrow()|• <br>called with a parameter of type STRING representing a<br>StudentID<br>• <br>search the array for loan records for the specified student<br>• <br>output a suitable message to say whether the student may, or<br>may not, borrow another book| ### (a) Write efficient pseudocode for the module OKToBorrow() <span class="part-marks">7 marks</span> ### (b) A second module is defined: <span class="part-marks">8 marks</span> |Module|Description| |---|---| |ReturnBook()|• <br>called with two parameters of type STRING representing a<br>StudentID and a BookID<br>• <br>searches the array for the relevant loan record<br>• <br>when found, sets OnLoan to FALSE and returns TRUE<br>• <br>if a loan record is not found, or the book has already been<br>returned, then returns FALSE| Write efficient pseudocode for the module ReturnBook() Assume that each student is only allowed to borrow each book only once. That means that there will be no more than one loan record for a given combination of student and book. ### (c) It is decided to introduce a system of fines for books that have been borrowed for too long. <span class="part-marks">2 marks</span> Two new requirements are defined: 1. Each loan has a maximum length, represented as a number of days. 2. Each book in the library will be assigned one of three categories. Each category has a different maximum loan length. Record structure and program design changes are needed to meet these two requirements. Outline the changes that are necessary to meet the two requirements.
Show mark scheme

8(a) [7 marks]

Example solution: PROCEDURE OKToBorrow(ThisStudentID : STRING) DECLARE Index, Count : INTEGER CONSTANT Max = 5  Count 0  Index 1 / 0 WHILE Index <= 5000 / Index <= 4999 AND Count < Max IF Loan[Index].StudentID = ThisStudentID AND __ Loan[Index].OnLoan = TRUE THEN  Count Count + 1 ENDIF  Index Index + 1 ENDWHILE IF Count < Max THEN OUTPUT "Student may borrow another book" ELSE OUTPUT "Student may not borrow another book" ENDIF ENDPROCEDURE Mark as follows: 1 Procedure heading, parameter and ending 2 Loop through all elements in array Loan 3 ... terminating if reached Max 4 Test for correct field in a loop StudentID 5 ... and that in a loop OnLoan = TRUE ... if so, then increment in a loop Count 6 Output an appropriate message in both cases after the loop

8(b)

WHILE Index < 5001 AND NOT Found IF Loan[Index].StudentID = ThisStudentID AND __ Loan[Index].BookID = ThisBookID THEN  Found TRUE IF Loan[Index].OnLoan = FALSE THEN // Already returned  OK FALSE ELSE  Loan[Index].OnLoan FALSE // Mark as returned now ENDIF ENDIF  Index Index + 1 ENDWHILE RETURN Found AND OK ENDFUNCTION

8(c) [2 marks]

Award marks for reference to following design features: Change to existing Record: 1 Store date due back as a new data item / in the loan record 2 Store date of loan and the loan length category as new data items / in the loan record Max 1 New Record 3 New Records with Category (and Loan length field) Change to Program: 4 (Use the loan length category of a book to) calculate the date due date 5 Compare due date with today’s date (to check if overdue / to calculate fine) 6 Map loan length category to length of loan / date due back Max 1 Max 2 marks

Q8
Oct/Nov 2025 Paper 2 v2

A program is being developed to manage student book loans from a college library.

The programmer has defined a record type to define each loan.

The data items are:

Data item Data type Comment
StudentID STRING the unique ID of the student who has borrowed the book
BookID STRING the unique ID of the book being borrowed
OnLoan BOOLEAN TRUE if the book has not been returned

The programmer has defined a global array Loan to store 7000 loan records.

There are more elements in the array than books in the library. Unused elements have the StudentID set to an empty string. These may occur anywhere in the array.

The programmer has defined a program module:

Module Description
CountLoans()
called with a parameter of type STRING representing a
StudentID

counts the number of books currently on loan to the
specified student

counts the number of books that the student has already
returned

output both counts together with a suitable message

(a) Write pseudocode for module CountLoans() 7 marks

(b) As a reminder, a global array Loan stores 7000 loan records with data items for each loan record: 7 marks

Data item Data type Comment
StudentID STRING the unique ID of the student who has borrowed the book
BookID STRING the unique ID of the book being borrowed
OnLoan BOOLEAN TRUE if the book has not been returned

A new module is defined:

Module Description
NewLoan()
called with two parameters of type STRING representing a
StudentID and a BookID

searches the array for an unused loan record

if found, updates the loan record and returns TRUE, otherwise
returns FALSE

Write efficient pseudocode for NewLoan()

(c) When a book is returned, the loan record will have its OnLoan data set to FALSE A new procedure Archive() will mark these records as unused after first saving them for future reference. 2 marks

Explain how these records can be saved for future reference.

(d) It is decided to extend the program so that a new module Reminder() will send an email to the student three days before the book is due to be returned. 2 marks

Outline the changes that will need to be made to the data stored and how this data will be used to generate the reminder email.

Data

Use

A program is being developed to manage student book loans from a college library. The programmer has defined a record type to define each loan. The data items are: |Data item|Data type|Comment| |---|---|---| |StudentID|STRING|the unique ID of the student who has borrowed the book| |BookID|STRING|the unique ID of the book being borrowed| |OnLoan|BOOLEAN|TRUE if the book has not been returned| The programmer has defined a global array Loan to store 7000 loan records. There are more elements in the array than books in the library. Unused elements have the StudentID set to an empty string. These may occur anywhere in the array. The programmer has defined a program module: |Module|Description| |---|---| |CountLoans()|• <br>called with a parameter of type STRING representing a<br>StudentID<br>• <br>counts the number of books currently on loan to the<br>specified student<br>• <br>counts the number of books that the student has already<br>returned<br>• <br>output both counts together with a suitable message| ### (a) Write pseudocode for module CountLoans() <span class="part-marks">7 marks</span> ### (b) As a reminder, a global array Loan stores 7000 loan records with data items for each loan record: <span class="part-marks">7 marks</span> |Data item|Data type|Comment| |---|---|---| |StudentID|STRING|the unique ID of the student who has borrowed the book| |BookID|STRING|the unique ID of the book being borrowed| |OnLoan|BOOLEAN|TRUE if the book has not been returned| A new module is defined: |Module|Description| |---|---| |NewLoan()|• <br>called with two parameters of type STRING representing a<br>StudentID and a BookID<br>• <br>searches the array for an unused loan record<br>• <br>if found, updates the loan record and returns TRUE, otherwise<br>returns FALSE| Write efficient pseudocode for NewLoan() ### (c) When a book is returned, the loan record will have its OnLoan data set to FALSE A new procedure Archive() will mark these records as unused after first saving them for future reference. <span class="part-marks">2 marks</span> Explain how these records can be saved for future reference. ### (d) It is decided to extend the program so that a new module Reminder() will send an email to the student three days before the book is due to be returned. <span class="part-marks">2 marks</span> Outline the changes that will need to be made to the data stored and how this data will be used to generate the reminder email. Data Use
Show mark scheme

8(a) [7 marks]

Example solution: PROCEDURE CountLoans(ThisStudentID : STRING) DECLARE Index, LCount, RCount : INTEGER  LCount 0  RCount 0  FOR Index 1 TO 7000 IF Loan[Index].StudentID = ThisStudentID THEN IF Loan[Index].OnLoan = FALSE THEN  RCount RCount + 1 ELSE  LCount LCount + 1 ENDIF ENDIF NEXT Index OUTPUT "Student has ", LCount, " books on loan" OUTPUT "and has returned ", RCount, " books" ENDPROCEDURE Mark as follows: MP1 Declaration of Index and two count variables MP2 Loop for 7000 iterations MP3 references an indexed data item with correct .dot notation Index MP4 Attempt to compare the field = parameter in a loop StudentID MP5 Test of the field and correct logic for both outcomes OnLoan MP6 Both count variables initialised and increment appropriate count in a loop MP7 Output includes both counts with a suitable message

8(b) [7 marks]

Example solution: FUNCTION NewLoan(ThisStudentID, ThisBookID : STRING) __ RETURNS BOOLEAN DECLARE Index : INTEGER DECLARE IsStored : BOOLEAN CONSTANT Blank = ""  Index 1  IsStored FALSE WHILE Index <= 7000 AND NOT IsStored IF Loan[Index].StudentID = Blank THEN  Loan[Index].StudentID ThisStudentID  Loan[Index].BookID ThisBookID  Loan[Index].OnLoan TRUE  IsStored TRUE ENDIF  Index Index + 1 ENDWHILE RETURN IsStored ENDFUNCTION Mark as follows: MP1 Loop through 7000 elements in array – correct loop structure Loan MP2 or until the first unused element is found // Correct inside a RETURN loop FOR MP3 Correct use of the indexed dot notation MP4 Test if record is unused ( in a loop .StudentID = "") MP5 Two item assignment statements correct MP6 assigned TRUE Loan[Index].OnLoan MP7 Correct logic to return in both cases (position found / no BOOLEAN position available) Alternative solution: loop only (no ‘found’ mechanism)  FOR Index 1 TO 7000 IF Loan[Index].StudentID = Blank THEN  Loan[Index].StudentID ThisStudentID  Loan[Index].BookID ThisBookID  Loan[Index].OnLoan TRUE RETURN TRUE ENDIF NEXT RETURN FALSE

8(c) [2 marks]

MP1 Save to/Open a (text) file MP2 Single line – form a string with separator characters and write to the file // Multiple lines

  • write each data item to a separate line in the file

8(d) [2 marks]

Additional date(s) solution MP1 Store the return date of each loan // the start date and the loan period MP2 Algorithm will do a calculation involving the MP1 data item(s) OR The student email address solution MP3 Store the student email address MP4 In order to send the email // the student is alerted to return the book Max 2

Q8
Oct/Nov 2025 Paper 2 v3

A program is being developed to manage student book loans from a college library.

The programmer has defined a record type to define each loan.

The data items are:

Data item Data type Comment
StudentID STRING the unique ID of the student who has borrowed
the book

The first three characters of a StudentID
represent a tutor ID. Each student has one tutor.
BookID STRING the unique ID of the book being borrowed
OnLoan BOOLEAN TRUE if the book has not been returned

The programmer has defined a global array Loan to store 8000 loan records.

There are more elements in the array than books in the library. Unused elements have the StudentID set to an empty string. These may occur anywhere in the array.

The programmer has defined a program module:

Module Description
LoanStatus()
called with two parameters of type STRING representing a
StudentID and a BookID

outputs a message saying whether a given loan has been
returned or not

outputs a warning message if a record of the given loan is
not found

(a) Write efficient pseudocode for the module LoanStatus() 8 marks

Assume that each combination of StudentID and BookID can occur only once.

(b) A second module is defined: 7 marks

Module Description
LoansPerTutor()
called with a parameter of type STRING representing
a tutor ID (as a reminder, the first three characters of
a StudentID represent a tutor ID)

returns an integer value representing the number of
books currently on loan to students who have the
given tutor

Reminder: unused elements have the StudentID set to an empty string. These may occur anywhere in the array.

Write pseudocode for the module LoansPerTutor()

(c) It is decided to mark as unused all records for book loans that have been returned. The data for these records will first be written to a new text file for archive purposes.

(i) The archive program will automatically generate a meaningful filename each time it is run. 2 marks

Outline a meaningful format to use for the filename.

(ii) There is a problem that will need to be overcome before the data items can be written to a text file. 1 mark

As a reminder, the data items are:

Data item Data type Comment
StudentID STRING the unique ID of the student who has borrowed the
book
The first three characters of a StudentID represent
a tutor ID. Each student has one tutor.
BookID STRING the unique ID of the book being borrowed
OnLoan BOOLEAN TRUE if the book has not been returned

Explain the problem.

(iii) One way of storing the data items in a text file is to store each data item on a separate line. 2 marks

Identify one benefit and one drawback of this way of storing the data.

Benefit

Drawback

A program is being developed to manage student book loans from a college library. The programmer has defined a record type to define each loan. The data items are: |Data item|Data type|Comment| |---|---|---| |StudentID|STRING|the unique ID of the student who has borrowed<br>the book<br> <br>The first three characters of a StudentID<br>represent a tutor ID. Each student has one tutor.| |BookID|STRING|the unique ID of the book being borrowed| |OnLoan|BOOLEAN|TRUE if the book has not been returned| The programmer has defined a global array Loan to store 8000 loan records. There are more elements in the array than books in the library. Unused elements have the StudentID set to an empty string. These may occur anywhere in the array. The programmer has defined a program module: |Module|Description| |---|---| |LoanStatus()|• <br>called with two parameters of type STRING representing a<br>StudentID and a BookID<br>• <br>outputs a message saying whether a given loan has been<br>returned or not<br>• <br>outputs a warning message if a record of the given loan is<br>not found| ### (a) Write efficient pseudocode for the module LoanStatus() <span class="part-marks">8 marks</span> Assume that each combination of StudentID and BookID can occur only once. ### (b) A second module is defined: <span class="part-marks">7 marks</span> |Module|Description| |---|---| |LoansPerTutor()|• <br>called with a parameter of type STRING representing<br>a tutor ID (as a reminder, the first three characters of<br>a StudentID represent a tutor ID)<br>• <br>returns an integer value representing the number of<br>books currently on loan to students who have the<br>given tutor| Reminder: unused elements have the StudentID set to an empty string. These may occur anywhere in the array. Write pseudocode for the module LoansPerTutor() ### (c) It is decided to mark as unused all records for book loans that have been returned. The data for these records will first be written to a new text file for archive purposes. #### (i) The archive program will automatically generate a meaningful filename each time it is run. <span class="part-marks">2 marks</span> Outline a meaningful format to use for the filename. #### (ii) There is a problem that will need to be overcome before the data items can be written to a text file. <span class="part-marks">1 mark</span> As a reminder, the data items are: |Data item|Data type|Comment| |---|---|---| |StudentID|STRING|the unique ID of the student who has borrowed the<br>book<br>The first three characters of a StudentID represent<br>a tutor ID. Each student has one tutor.| |BookID|STRING|the unique ID of the book being borrowed| |OnLoan|BOOLEAN|TRUE if the book has not been returned| Explain the problem. #### (iii) One way of storing the data items in a text file is to store each data item on a separate line. <span class="part-marks">2 marks</span> Identify one benefit and one drawback of this way of storing the data. Benefit Drawback
Show mark scheme

8(a) [8 marks]

Example solution: PROCEDURE LoanStatus(ThisStudentID, ThisBookID : STRING) DECLARE Index : INTEGER DECLARE Found : BOOLEAN  Index 1 / 0  Found FALSE WHILE Index <= 8000 / 7999 AND NOT Found IF Loan[Index].StudentID = ThisStudentID AND Loan[Index].BookID = ThisBookID THEN IF Loan[Index].OnLoan = FALSE THEN OUTPUT "Loan has been returned." ELSE OUTPUT "Loan has not been returned." ENDIF  Found TRUE ENDIF  Index Index + 1 ENDWHILE IF NOT Found THEN OUTPUT "Warning - Loan not found." ENDIF ENDPROCEDURE Mark as follows: 1 Procedure heading, parameters and ending 2 Loop through all elements in array Loan 3 ... or until record loan is found 4 Test for correct in a loop StudentID 5 ... and correct BookID 6 ... check data item OnLoan 7 ... and output both messages as appropriate regarding book loan status once 8 If no matching loan found, Output 'not found' after the loop

8(b) [7 marks]

Example solution: FUNCTION LoansPerTutor(TutorID : STRING) RETURNS INTEGER DECLARE Index, Count : INTEGER  Count 0  FOR Index 1 / 0 TO 8000 / 7999 IF LEFT(Loan[Index].StudentID, 3) = TutorID AND Loan[Index].OnLoan = TRUE THEN  Count Count + 1 ENDIF NEXT Index RETURN Count ENDFUNCTION Mark as follows: 1 Initialise local integer for Count 2 Loop through all elements in the array Loan 3 Attempt at referencing a data item in a loop 4 Extract from in a loop TutorID Loan[Index].StudentID 5 Test for Matching Tutor AND test if the book has been returned using correct dot notation in a loop 6 ... if true then increment in a loop Count 7 Return count

8(c)(i) [2 marks]

One mark per point: 1 Include (a suffix string based on) the date of the archive / the next number in sequence 2 Concatenate with a root filename such as 'Archive'

8(c)(ii) [1 mark]

Boolean data cannot be written to a text file // is not a string // OnLoan will have to be converted to text OnLoan

8(c)(iii) [2 marks]

One mark per point: Benefit: Algorithm to store / extract a record is easier // unpacking of data is not required // No need for string concatenation Drawback: More file accesses needed (to read / write a complete record)

Q1
May/Jun 2025 Paper 2 v1

A program is being developed to help the manager of a shop control the stock.

(a) An identifier table has been used during the design stage. 4 marks

Complete the identifier table:

Example value Explanation Variable name Data type
"Fruit" a category of stock
that is sold in the shop
20/02/2025 when an item was
sold
12.67 the cost of an item
TRUE to indicate if an item is
in stock

(b) A module Sales() is part of the stock control program. 5 marks

The table contains pseudocode extracts from the module Sales()

Each extract may include all or part of:

  • assignment

  • selection

  • iteration (repetition).

Complete the table by placing one or more ticks (✓) in each row:

Pseudocode extract Assignment Selection Iteration
Result
CalculateTotal()
WHILE IsClosed
REPEAT
INPUT Value
UNTIL Sales[4] > Value
IF Sales[Current] <= 150 THEN
Discount
TRUE
ENDIF
CASE OF Option
A program is being developed to help the manager of a shop control the stock. ### (a) An identifier table has been used during the design stage. <span class="part-marks">4 marks</span> Complete the identifier table: |Example value|Explanation|Variable name|Data type| |---|---|---|---| |"Fruit"|a category of stock<br>that is sold in the shop||| |20/02/2025|when an item was<br>sold||| |12.67|the cost of an item||| |TRUE|to indicate if an item is<br>in stock||| ### (b) A module Sales() is part of the stock control program. <span class="part-marks">5 marks</span> The table contains pseudocode extracts from the module Sales() Each extract may include all or part of: - assignment - selection - iteration (repetition). Complete the table by placing one or more ticks (✓) in each row: |Pseudocode extract|Assignment|Selection|Iteration| |---|---|---|---| |Result<br> CalculateTotal()|||| |WHILE IsClosed|||| |REPEAT<br> INPUT Value<br>UNTIL Sales[4] > Value|||| |IF Sales[Current] <= 150 THEN<br> Discount<br> TRUE<br>ENDIF|||| |CASE OF Option||||
Show mark scheme

1(a) [4 marks]

Example Explanation Variable name Data type value "Fruit" Category STRING a category of stock that is sold in the shop DateSold DATE when an item was sold 12.67 (Item)Cost/Price REAL the cost of an item TRUE (Item)InStock BOOLEAN to indicate if an item is in stock and data type

1(b) [5 marks]

Pseudocode extract Assignment Selection Iteration  ✓ CalculateTotal() ✓ ✓ ✓ ✓ ✓  TRUE ✓

1(c) [3 marks]

Breaking down a problem into sub problems In order to explain / understand the process/task of how a (stock control) can be managed in more detail Leading to the concept of the program designed as a series of modules / procedures / functions // or by example of different stock control modules Makes the program easier to test / debug if no mention of stock control

Q7
May/Jun 2025 Paper 2 v1

A program is being developed to implement a customer loyalty scheme for a coffee shop.

The programmer has decided that the following data items need to be stored for each customer:

Data item Description
customer ID a unique six-digit string
points an integer value that is increased by one for every cup of coffee the
customer orders

When a customer visits the shop and orders coffee, the scheme operates as follows:

  • The total number of points is increased by the number of coffees ordered.

  • If just one cup of coffee is ordered and the number of points goes above 10, then:

  • the cup of coffee they have just ordered is given to them free of charge

  • the number of points is reduced by 11.

    • If the order is for multiple coffees and the number of points goes above 10, then:
  • they get one coffee free of charge for every 11 points

  • the number of points is reduced by 11 for each free coffee.

For example, the:

  • customer currently has 9 points

  • customer orders 16 cups of coffee

  • total number of points now becomes 25

  • customer gets 2 free coffees and now has 3 points left.

The programmer has defined a program module that is called every time a customer places an order:

Module Description
CustomerOrder()
called with two integer parameters:

the number of coffees ordered

the current number of points

output a suitable message giving the number of free coffees

return a value for the new points total.

(a) Write pseudocode for module CustomerOrder() 6 marks

(b) A text file Loyalty.txt will be used to store the data items for the loyalty scheme. The data items for each customer will be stored on a separate line of the text file where each data item is separated by a comma:

<CustomerID>,<Points>

The contents of the text file Loyalty.txt will always be stored in ascending order by customer ID.

When the data items are read from or written to the text file Loyalty.txt, they may need to be converted to the appropriate data type.

Each customer has a unique customer ID starting at "100001" with this value increasing by one each time a new customer joins the loyalty scheme.

When a customer joins the loyalty scheme, they are assigned the next customer ID and value of points is set to 0.

For example, if the loyalty scheme has 204 customers and a new customer joins the loyalty scheme, the following line is added to the text file Loyalty.txt:

"100205,0"

You can assume that the number of customers in the loyalty scheme will never be more than 9000. The programmer has defined a program module as follows:

Module Description
AddNewCustomers()
called with an integer parameter representing the number of
new customers to be added to the loyalty scheme

adds a new line, containing the required information, to the
text file Loyalty.txt for each customer added to the loyalty
scheme

outputs each new customer ID added to the loyalty scheme

(i) Write pseudocode for module AddNewCustomers() 8 marks

Assume that there is at least one customer already in the loyalty scheme.

(ii) The requirements for AddNewCustomers() are changed. There may be no existing customers in the loyalty scheme. 4 marks

Explain the changes that will need to be made to the module AddNewCustomers()

A program is being developed to implement a customer loyalty scheme for a coffee shop. The programmer has decided that the following data items need to be stored for each customer: |Data item|Description| |---|---| |customer ID|a unique six-digit string| |points|an integer value that is increased by one for every cup of coffee the<br>customer orders| When a customer visits the shop and orders coffee, the scheme operates as follows: - The total number of points is increased by the number of coffees ordered. - If just one cup of coffee is ordered and the number of points goes above 10, then: - the cup of coffee they have just ordered is given to them free of charge - the number of points is reduced by 11. - If the order is for multiple coffees and the number of points goes above 10, then: - they get one coffee free of charge for every 11 points - the number of points is reduced by 11 for each free coffee. For example, the: - customer currently has 9 points - customer orders 16 cups of coffee - total number of points now becomes 25 - customer gets 2 free coffees and now has 3 points left. The programmer has defined a program module that is called every time a customer places an order: |Module|Description| |---|---| |CustomerOrder()|• <br>called with two integer parameters:<br> ◦<br>the number of coffees ordered<br> ◦<br>the current number of points<br>• <br>output a suitable message giving the number of free coffees<br>• <br>return a value for the new points total.| ### (a) Write pseudocode for module CustomerOrder() <span class="part-marks">6 marks</span> ### (b) A text file Loyalty.txt will be used to store the data items for the loyalty scheme. The data items for each customer will be stored on a separate line of the text file where each data item is separated by a comma: &lt;CustomerID&gt;,&lt;Points&gt; The contents of the text file Loyalty.txt will always be stored in ascending order by customer ID. When the data items are read from or written to the text file Loyalty.txt, they may need to be converted to the appropriate data type. Each customer has a unique customer ID starting at "100001" with this value increasing by one each time a new customer joins the loyalty scheme. When a customer joins the loyalty scheme, they are assigned the next customer ID and value of points is set to 0. For example, if the loyalty scheme has 204 customers and a new customer joins the loyalty scheme, the following line is added to the text file Loyalty.txt: "100205,0" You can assume that the number of customers in the loyalty scheme will never be more than 9000. The programmer has defined a program module as follows: |Module|Description| |---|---| |AddNewCustomers()|• <br>called with an integer parameter representing the number of<br>new customers to be added to the loyalty scheme<br>• <br>adds a new line, containing the required information, to the<br>text file Loyalty.txt for each customer added to the loyalty<br>scheme<br>• <br>outputs each new customer ID added to the loyalty scheme| #### (i) Write pseudocode for module AddNewCustomers() <span class="part-marks">8 marks</span> Assume that there is at least one customer already in the loyalty scheme. #### (ii) The requirements for AddNewCustomers() are changed. There may be no existing customers in the loyalty scheme. <span class="part-marks">4 marks</span> Explain the changes that will need to be made to the module AddNewCustomers()
Show mark scheme

7(a) [6 marks]

INTEGER  Points + Number  0  NumberFree + 1  NewPoints -11  Number - 1 Function header and ending and parameters and return type Number of coffees ordered added to points Correct calculation of one free coffee Attempted calculation of multiple free coffees and reduced NewPoints Output number of free drinks with suitable message Return of NewPoints

7(b)(i) [8 marks]

 STR_TO_NUM((LEFT(Line, 6))  1 TO NumToAdd  CustomerID + 1  NUM_TO_STR(CustomerID) & ",0" All variables used are declared using the correct type including a string and an integer Open file in read mode and close (before opening in append mode) Conditional loop with EOF("Loyalty.txt") Read from file // Count number of records in the file Line Open the file in append mode and subsequently close Extract from and convert to integer // use count from CustomerID Line MP4 to generate last stored CustomerID A (count controlled) loop for the number of customers to add Increment and output the new in loop CustomerID CustomerID Create string for new and write to file in loop CustomerID Check if the text file exists / is empty

7(b)(ii) [4 marks]

loyalty.txt If file does not exist it must be created (using write mode) If the file has to be created / is empty then set the first to CustomerID 100001 Write to (using write mode) "100001,0" loyalty.txt For all but the first customer (to be added to the empty file) use the existing code / module

Q7
May/Jun 2025 Paper 2 v3

A program is being developed to implement a customer loyalty scheme for a coffee shop.

The programmer has decided that the following data items need to be stored for each customer:

Data item Description
customer ID a unique six-digit string
loyalty points an integer value that depends on how often the customer visits the coffee shop
last visit date the date the customer last visited the coffee shop

The programmer has defined a program module:

Module Description
UpdateVisit() • called with two parameters:
1. loyalty points of type INTEGER
2. last visit date of type DATE
• change the loyalty points:
 increase by four if the last visit date and the current date are in the
same month
 otherwise increase by one
• change the last visit date to the current date
• the changed values must be available to the code that follows the call
to UpdateVisit()

(a) (i) Write pseudocode for module UpdateVisit() 5 marks

Assume the customer has made at least one previous visit.

(ii) The programmer decides to amend the UpdateVisit() module so that loyalty points are further increased if the customer visits the coffee shop the same day of the week as their last visit. 1 mark

Write the pseudocode for this condition.

(b) A text file Loyalty.txt will be used to store the data items for the loyalty scheme.

The text file Loyalty.txt contains only one line of data for each customer.

Each data item is separated by a comma:

<CustomerID>,<LoyaltyPointsString>,<LastVisitDateString>

LastVisitDateString is always eight characters in length in the format: DDMMYYYY.

An example of how a line of data will be stored in the text file Loyalty.txt is:

"100123,132,05032025"

This example shows that the customer with an ID of 100123 had 132 loyalty points following their last visit to the coffee shop on 05/03/2025.

If a customer visits the coffee shop on a Monday, the value of their loyalty points is increased by 10.

The programmer has defined two more program modules:

Module Description
FindCustomer()
(is already written)
• called with a parameter of type STRING that represents a
customer ID
• returns the line of data read from the text file Loyalty.txt
containing the data items for that customer
MondayCheck() • called with a parameter of type STRING that represents the
customer ID of a customer
• calls FindCustomer()
• extracts the loyalty points from the string returned by
FindCustomer()
• increases the loyalty points for the current customer by 10 if the
day visited is a Monday
• returns an integer value representing the loyalty points

(i) Write pseudocode for module MondayCheck() 8 marks

The module FindCustomer() must be used and assume it returns a valid string for the current customer.

(ii) A date is stored in LastVisitDateString in the format: 4 marks

DDMMYYYY

DD is a 2-digit string MM is a 2-digit string YYYY is a 4-digit string.

For example, the date 03/09/2024 is stored as "03092024"

An algorithm is needed to convert the string stored in LastVisitDateString to data type DATE which is then stored in the variable LastVisitDate.

Complete the pseudocode for this algorithm:

Assume that LastVisitDateString has been declared and contains valid data.

DECLARE DayInt, MonthInt, YearInt : INTEGER

DECLARE LastVisitDate : DATE

A program is being developed to implement a customer loyalty scheme for a coffee shop. The programmer has decided that the following data items need to be stored for each customer: |Data item|Description| |---|---| |customer ID|a unique six-digit string| |loyalty points|an integer value that depends on how often the customer visits the coffee shop| |last visit date|the date the customer last visited the coffee shop| The programmer has defined a program module: |Module|Description| |---|---| |UpdateVisit()|• called with two parameters:<br>1. loyalty points of type INTEGER<br>2. last visit date of type DATE<br>• change the loyalty points:<br>  increase by four if the last visit date and the current date are in the<br>same month<br>  otherwise increase by one<br>• change the last visit date to the current date<br>• the changed values must be available to the code that follows the call<br>to UpdateVisit()| ### (a) (i) Write pseudocode for module UpdateVisit() <span class="part-marks">5 marks</span> Assume the customer has made at least one previous visit. #### (ii) The programmer decides to amend the UpdateVisit() module so that loyalty points are further increased if the customer visits the coffee shop the same day of the week as their last visit. <span class="part-marks">1 mark</span> Write the pseudocode for this condition. ### (b) A text file Loyalty.txt will be used to store the data items for the loyalty scheme. The text file Loyalty.txt contains only one line of data for each customer. Each data item is separated by a comma: &lt;CustomerID&gt;,&lt;LoyaltyPointsString&gt;,&lt;LastVisitDateString&gt; LastVisitDateString is always eight characters in length in the format: DDMMYYYY. An example of how a line of data will be stored in the text file Loyalty.txt is: "100123,132,05032025" This example shows that the customer with an ID of 100123 had 132 loyalty points following their last visit to the coffee shop on 05/03/2025. If a customer visits the coffee shop on a Monday, the value of their loyalty points is increased by 10. The programmer has defined two more program modules: |Module|Description| |---|---| |FindCustomer()<br>(is already written)|• called with a parameter of type STRING that represents a<br>customer ID<br>• returns the line of data read from the text file Loyalty.txt<br>containing the data items for that customer| |MondayCheck()|• called with a parameter of type STRING that represents the<br>customer ID of a customer<br>• calls FindCustomer()<br>• extracts the loyalty points from the string returned by<br>FindCustomer()<br>• increases the loyalty points for the current customer by 10 if the<br>day visited is a Monday<br>• returns an integer value representing the loyalty points| #### (i) Write pseudocode for module MondayCheck() <span class="part-marks">8 marks</span> The module FindCustomer() must be used and assume it returns a valid string for the current customer. #### (ii) A date is stored in LastVisitDateString in the format: <span class="part-marks">4 marks</span> DDMMYYYY DD is a 2-digit string MM is a 2-digit string YYYY is a 4-digit string. For example, the date 03/09/2024 is stored as "03092024" An algorithm is needed to convert the string stored in LastVisitDateString to data type DATE which is then stored in the variable LastVisitDate. Complete the pseudocode for this algorithm: Assume that LastVisitDateString has been declared and contains valid data. DECLARE DayInt, MonthInt, YearInt : INTEGER DECLARE LastVisitDate : DATE
Show mark scheme

7(a)(i) [5 marks]

Example solution: PROCEDURE UpdateVisit(BYREF LastVisitDate : DATE,__ BYREF LoyaltyPoints : INTEGER) IF MONTH(TODAY()) = MONTH(LastVisitDate) THEN  LoyaltyPoints LoyaltyPoints + 4 ELSE  LoyaltyPoints LoyaltyPoints + 1 ENDIF  LastVisitDate TODAY() ENDPROCEDURE MP1 Procedure heading and ending and two parameters of correct type MP2 … both passed BYREF MP3 Use of function to obtain current date TODAY()  MP4 Use function ( 2) and one parameter is the header parameter MONTH and 2nd parameter is / assigned variable TODAY() MP5 If visit is same month, increase by 4 otherwise LoyaltyPoints increase by 1 MP6 set to / ‘current date’ variable (assigned LastVisitDate TODAY() or unassigned) Max 5 DAYINDEX(LastVisitDate) = DAYINDEX(TODAY())

7(b)(i)

Alternative example solution: Uses a loop to calculate the number of digits in the string LoyaltyPoints FUNCTION MondayCheck(CustomerID : STRING) RETURNS INTEGER DECLARE LoyaltyPoints : INTEGER DECLARE LoyaltyPointsString : STRING DECLARE Index : INTEGER DECLARE Line : STRING  Line FindCustomer(CustomerID)  Index 9 WHILE MID(Line, Index, 1) <> ','  Index Index + 1 ENDWHILE // calculate the number of digits in LoyaltyPoints string  LoyaltyPointsString MID(Line, 8, Index - 8)  LoyaltyPoints STR_TO_NUM(LoyaltyPointsString) IF DAYINDEX(TODAY()) = 2 THEN  LoyaltyPoints LoyaltyPoints + 10 ENDIF RETURN LoyaltyPoints ENDFUNCTION

7(b)(ii) [4 marks]

Example solution:  DayInt STR_TO_NUM(LEFT(LastVisitDateString, 2))  MonthInt STR_TO_NUM(MID(LastVisitDateString, 3, 2))  YearInt STR_TO_NUM(RIGHT(LastVisitDateString, 4))  LastVisitDate SETDATE(DayInt, MonthInt, YearInt) Mark as follows: MP1 Use of one substring function MP2 , and all correctly extracted DayInt MonthInt YearInt MP3 Use of x 3 STR_TO_NUM MP4 function used to convert to a date type and assigned to SETDATE() LastVisitDate

Q7
Oct/Nov 2024 Paper 2 v2

A coffee shop runs a computerised loyalty card system.

Customers are issued with a loyalty card with their name together with a unique customer ID.

Loyalty points are added to their card each time they spend money at the shop.

The following information is stored for each customer: ID, name, home address, email address, mobile phone number, date of birth, number of points, date of last visit and amount of money spent at last visit.

A new module will generate a personalised email message to each loyalty card customer who has not visited the coffee shop in the last three months. The message will include a unique voucher code which can be used to authorise a discount if the customer goes to the shop within the next two weeks.

(a) Identify three items of customer information that will be used by the new module and justify your choices. 3 marks

Item 1

Justification

Item 2

Justification

Item 3

Justification

(b) Identify the computational thinking skill that you needed to use to answer part (a). 1 mark

(c) It is decided to adopt a formal program development life cycle model for the development of the new module. 3 marks

The analysis of the new module is complete and the project moves on to the design stage. During this stage all the necessary algorithms and module designs will be defined.

State three other items that will be defined for the new module during the design stage.

1

2

3

(d) Part of the coffee shop program contains three program modules as follows: 3 marks

  • Module Init() has no parameters and returns a Boolean.

  • Module Reset() takes a string as a parameter and returns an Integer.

  • Module Check() repeatedly calls Init() followed by Reset().

Draw a structure chart to represent the relationship between the three modules, including all parameters and return values.

A coffee shop runs a computerised loyalty card system. Customers are issued with a loyalty card with their name together with a unique customer ID. Loyalty points are added to their card each time they spend money at the shop. The following information is stored for each customer: ID, name, home address, email address, mobile phone number, date of birth, number of points, date of last visit and amount of money spent at last visit. A new module will generate a personalised email message to each loyalty card customer who has not visited the coffee shop in the last three months. The message will include a unique voucher code which can be used to authorise a discount if the customer goes to the shop within the next two weeks. ### (a) Identify three items of customer information that will be used by the new module and justify your choices. <span class="part-marks">3 marks</span> Item 1 Justification Item 2 Justification Item 3 Justification ### (b) Identify the computational thinking skill that you needed to use to answer part (a). <span class="part-marks">1 mark</span> ### (c) It is decided to adopt a formal program development life cycle model for the development of the new module. <span class="part-marks">3 marks</span> The analysis of the new module is complete and the project moves on to the design stage. During this stage all the necessary algorithms and module designs will be defined. State three other items that will be defined for the new module during the design stage. 1 2 3 ### (d) Part of the coffee shop program contains three program modules as follows: <span class="part-marks">3 marks</span> - Module Init() has no parameters and returns a Boolean. - Module Reset() takes a string as a parameter and returns an Integer. - Module Check() repeatedly calls Init() followed by Reset(). Draw a structure chart to represent the relationship between the three modules, including all parameters and return values.
Show mark scheme

7(a) [3 marks]

Customer ID – to reference the other customer details • Email address – to send the email • Name – to personalise the email • Date of last visit – to select which customers should receive an email • Unique voucher code (or method of code generation) – to include in the email Mark as follows: One mark per item and justification Max 3 marks

7(b) [1 mark]

Abstraction

7(c) [3 marks]

MP1 Data structures // data dictionary / / identifier table(s) // validation rules MP2 Data-flow diagram // state-transition diagram MP3 User interface // Format for the email MP4 Testing method / Test plan / Test data / Trace tables MP5 Choice of email protocol to be used // Programming language to be used // Development environment MP6 Use of library routines // program to send the email Max 3 marks

7(d) [3 marks]

MP1 Three boxes correctly labelled and correct hierarchy MP2 Parameter and return values MP3 Iteration arrow

Q8
Oct/Nov 2024 Paper 2 v2

A program is being developed to implement a game for up to six players.

During the game, each player assembles a team of characters. At the start of the game there are 45 characters available.

Each character has four attributes, as follows:

Attribute Examples Comment
Player 0, 1, 3 The player the character is assigned to.
Role Builder, Teacher, Doctor The job that the character will perform in the
game.
Name Bill, Lee, Farah, Mo The name of the character. Several characters
may perform the same role, but they will each
have a unique name.
Level 14, 23, 76 The skill level of the character. An integer in the
range 0 to 100 inclusive.

The programmer has defined a record type to define each character.

The record type definition is shown in pseudocode as follows:

TYPE CharacterType DECLARE Player : INTEGER DECLARE Role : STRING DECLARE Name : STRING DECLARE Level : INTEGER ENDTYPE

The Player field indicates the player to which the character is assigned (1 to 6). The field value is 0 if the character is not assigned to any player.

The programmer has defined a global array to store the character data as follows:

DECLARE Character : ARRAY[1:45] OF CharacterType

At the start of the game all record fields are initialised, and all Player field values are set to 0

The programmer has defined a program module as follows:

Module Description
Assign()
called with two parameters:


an integer representing a player


a string representing a character role

search the Character array for an unassigned character with the
required role

If found, assign the character to the given player and output a confirmation
message, for example:

"Bill the Builder has been assigned to player 3"

If no unassigned character with the required role is found, output a suitable
message.

(a) Write pseudocode for module Assign(). 7 marks

(b) A new module will store the contents of the Character array in a text file. 7 marks

The module is defined as follows:

Module Description
Save()
form a string from each record with fields separated by the
character '^'

write each string to a separate line of the new file named
SaveFile.txt

Complete the pseudocode for module Save().

PROCEDURE Save()

ENDPROCEDURE

(c) The program is changed and the record type definition is modified as follows: 2 marks

TYPE CharacterType DECLARE Player : INTEGER DECLARE Role : STRING DECLARE Name : STRING DECLARE Level : INTEGER DECLARE Status : BOOLEAN ENDTYPE

Describe how the additional Boolean field may be stored with the rest of the fields on one line of a text file.

(d) The save operation is to be extended so that multiple files may be saved as the game progresses. This will allow the user to restore the game from any saved position. The filename must reflect the sequence in which the files are saved. 2 marks

Describe a method that would allow multiple files to be saved and give an example of two consecutive filenames.

Method

Example

A program is being developed to implement a game for up to six players. During the game, each player assembles a team of characters. At the start of the game there are 45 characters available. Each character has four attributes, as follows: |Attribute|Examples|Comment| |---|---|---| |Player|0, 1, 3|The player the character is assigned to.| |Role|Builder, Teacher, Doctor|The job that the character will perform in the<br>game.| |Name|Bill, Lee, Farah, Mo|The name of the character. Several characters<br>may perform the same role, but they will each<br>have a unique name.| |Level|14, 23, 76|The skill level of the character. An integer in the<br>range 0 to 100 inclusive.| The programmer has defined a record type to define each character. The record type definition is shown in pseudocode as follows: TYPE CharacterType DECLARE Player : INTEGER DECLARE Role : STRING DECLARE Name : STRING DECLARE Level : INTEGER ENDTYPE The Player field indicates the player to which the character is assigned (1 to 6). The field value is 0 if the character is not assigned to any player. The programmer has defined a global array to store the character data as follows: DECLARE Character : ARRAY[1:45] OF CharacterType At the start of the game all record fields are initialised, and all Player field values are set to 0 The programmer has defined a program module as follows: |Module|Description| |---|---| |Assign()|• <br>called with two parameters:<br> <br>○<br>an integer representing a player<br> <br>○<br>a string representing a character role<br>• <br>search the Character array for an unassigned character with the<br>required role<br>• <br>If found, assign the character to the given player and output a confirmation<br>message, for example:<br> <br>"Bill the Builder has been assigned to player 3"<br>• <br>If no unassigned character with the required role is found, output a suitable<br>message.| ### (a) Write pseudocode for module Assign(). <span class="part-marks">7 marks</span> ### (b) A new module will store the contents of the Character array in a text file. <span class="part-marks">7 marks</span> The module is defined as follows: |Module|Description| |---|---| |Save()|• <br>form a string from each record with fields separated by the<br>character '^'<br>• <br>write each string to a separate line of the new file named<br>SaveFile.txt| Complete the pseudocode for module Save(). PROCEDURE Save() ENDPROCEDURE ### (c) The program is changed and the record type definition is modified as follows: <span class="part-marks">2 marks</span> TYPE CharacterType DECLARE Player : INTEGER DECLARE Role : STRING DECLARE Name : STRING DECLARE Level : INTEGER DECLARE Status : BOOLEAN ENDTYPE Describe how the additional Boolean field may be stored with the rest of the fields on one line of a text file. ### (d) The save operation is to be extended so that multiple files may be saved as the game progresses. This will allow the user to restore the game from any saved position. The filename must reflect the sequence in which the files are saved. <span class="part-marks">2 marks</span> Describe a method that would allow multiple files to be saved and give an example of two consecutive filenames. Method Example
Show mark scheme

8(a) [7 marks]

Example solution: PROCEDURE Assign(ThisRole : STRING, ThisPlayer : INTEGER) DECLARE Index : INTEGER DECLARE Done : BOOLEAN  Done FALSE  Index 1 WHILE Index < 46 AND Done = FALSE IF Character[Index].Player = 0 AND __ Character[Index].Role = ThisRole THEN  Character[Index].Player ThisPlayer  Done TRUE ELSE  Index Index + 1 ENDIF ENDWHILE IF Done = TRUE THEN OUTPUT Character[Index].Name, the ,__ " " Character[Index].Role, __ has been assigned to player , ThisPlayer " " ELSE OUTPUT No characters with this role are available " " ENDIF ENDPROCEDURE Mark as follows: MP1 Loop until ‘found’ or all 45 elements considered MP2 Test of field – i.e. not value in a loop Player MP3 ... – i.e. match for parameter in a loop AND Role ThisRole MP4 If available character found, assign to the character in a ThisPlayer loop MP5 When character found set termination condition/flag MP6 Both OUTPUT messages logically correctly placed MP7 Both OUTPUT statements correctly formed

8(b) [7 marks]

Example solution: PROCEDURE Save() DECLARE Index : INTEGER DECLARE Line : STRING CONSTANT SEP = '^' OPENFILE SaveFile.txt FOR WRITE " "  FOR Index 1 TO 45  Line NUM_TO_STR(Character[Index].Player) & SEP  Line Line & Character[Index].Role & SEP  Line Line & Character[Index].Name & SEP  Line Line & NUM_TO_STR(Character[Index].Level) WRITEFILE SaveFile.txt , Line " " NEXT Index CLOSEFILE SaveFile.txt " " ENDPROCEDURE Mark as follows: MP1 Declaration of local integer for ( and string type for Index Line) MP2 Open in write mode and subsequently close "SaveFile.txt" MP3 Loop through 45 elements MP4 Attempt to form

  • four fields in a loop Line MP5 Correct use of in a loop NUM_TO_STR()x2 (Player and Level) MP6 Correct use of three && in a loop strings MP7 Line from MP4 written to file in a loop

8(c) [2 marks]

MP1 Encode as a character / string Status MP2 Append the ‘^’ separator and the character/string

8(d) [2 marks]

MP1 Method: Create a filename suffix which is incremented for each file save MP2 Example: SaveFile01.txt, SaveFile02.txt

Q3
Oct/Nov 2024 Paper 2 v3

The implementation of a linked list uses an integer variable and a 1D array List of type Node.

Record type Node is declared in pseudocode as follows:

TYPE Node DECLARE Data : STRING DECLARE Pointer : INTEGER ENDTYPE

The array List is declared in pseudocode as follows:

DECLARE List : ARRAY[1:200] OF Node

The linked list will operate as follows:

  • Integer variable HeadPointer will store the array index for the first node in the linked list.

  • The Pointer field of a node contains the index value of the next array element (the next node) in the linked list.

  • The value 0 is used as a null pointer.

(a) (i) State why the value 0 has been selected as the null pointer. 1 mark

(ii) Give the range of valid values that could be assigned to variable HeadPointer. 1 mark

The implementation of a linked list uses an integer variable and a 1D array List of type Node. Record type Node is declared in pseudocode as follows: TYPE Node DECLARE Data : STRING DECLARE Pointer : INTEGER ENDTYPE The array List is declared in pseudocode as follows: DECLARE List : ARRAY[1:200] OF Node The linked list will operate as follows: - Integer variable HeadPointer will store the array index for the first node in the linked list. - The Pointer field of a node contains the index value of the next array element (the next node) in the linked list. - The value 0 is used as a null pointer. ### (a) (i) State why the value 0 has been selected as the null pointer. <span class="part-marks">1 mark</span> #### (ii) Give the range of valid values that could be assigned to variable HeadPointer. <span class="part-marks">1 mark</span>
Show mark scheme

3(a)(i) [1 mark]

0 is not a valid array / index value // No 0 element in the array th List

3(a)(ii) [1 mark]

to 0 200

3(b) [4 marks]

Mark as follows: MP1 Use of variable as array index and initialisation to 1 / to first element of array MP2 Loop for 199 / 200 iterations MP3 Assign Index+1 to each pointer field in a loop MP4 Assign 0 to 200 pointer field th

3(c) [4 marks]

One mark per step: MP1 Assign to / Current Pointer // Identify HeadPointer ThisPointer first node using headpointer MP2 Loop the following until value is 0 (zero) / null pointer ThisPointer reached MP3 … Output data (field) from array element at index // ThisPointer Output data (field) of the current node / array element MP4 … Assign pointer field from current array element / index / to / Current Pointer // Assign pointer field from current ThisPointer node to / Current Pointer ThisPointer

Q8
Oct/Nov 2024 Paper 2 v3

A program is being developed to implement a game for up to six players.

During the game, each player assembles a team of characters. At the start of the game there are 45 characters available.

Each character has four attributes, as follows:

Attribute Examples Comment
Player 0, 1, 3 The player the character is assigned to.
Role Builder, Teacher, Doctor The job that the character will perform in the
game.
Name Bill, Lee, Farah, Mo The name of the character. Several characters
may perform the same role, but they will each
have a unique name.
Skill level 14, 23, 76 An integer in the range 0 to 100, inclusive.

The programmer has defined a record type to define each character. The record type definition is shown in pseudocode as follows:

TYPE CharacterType DECLARE Player : INTEGER DECLARE Role : STRING DECLARE Name : STRING DECLARE SkillLevel : INTEGER ENDTYPE

The Player field indicates the player to which the character is assigned (1 to 6). This field value is 0 if the character is not assigned to any player.

The programmer has defined a global array to store the character data, as follows:

DECLARE Character : ARRAY[1:45] OF CharacterType

At the start of the game all record fields are initialised, and all Player fields are set to 0

The programmer has defined a program module as follows:

Module Description
Count()
called with two parameters:


an integer representing a player


a string representing a character role

searches the Character array for characters with the given role that are
assigned to the given player

counts the number of assigned characters and sums their total skill level

outputs the result of the search if characters with the given role are found,
for example:

"Player 3 has 4 characters with the role of Teacher
and the total skill level is 65"

if no characters with the given role are found, outputs:

"No characters with that role are assigned to this
player"

(a) Complete the pseudocode for module Count(). 7 marks

PROCEDURE Count(ThisPlayer : INTEGER, ThisRole : STRING)

ENDPROCEDURE

(b) The Character array data has been saved in the text file SaveFile.txt Each line of the file contains one element of the array (one record). 7 marks

New modules are defined:

Module Description
Extract()
(already written)

called with two parameters:


a string representing a complete line from the text file


an integer representing a field number (see structure below)

returns a string representing the required field
Restore()
opens the text file SaveFile.txt

reads lines from the file and assigns values to each record in the
Character array using data from each line of the file

As a reminder, the record structure is repeated here:

TYPE CharacterType DECLARE Player : INTEGER //Field number 1 DECLARE Role : STRING //Field number 2 DECLARE Name : STRING //Field number 3 DECLARE SkillLevel : INTEGER //Field number 4 ENDTYPE

Write pseudocode for module Restore().

You must use the module Extract().

(c) The game can last for several days and users often find that they have to close and rerun the game program many times in order to complete it. 2 marks

Describe the benefit of using the file SaveFile.txt as described in part (b).

A program is being developed to implement a game for up to six players. During the game, each player assembles a team of characters. At the start of the game there are 45 characters available. Each character has four attributes, as follows: |Attribute|Examples|Comment| |---|---|---| |Player|0, 1, 3|The player the character is assigned to.| |Role|Builder, Teacher, Doctor|The job that the character will perform in the<br>game.| |Name|Bill, Lee, Farah, Mo|The name of the character. Several characters<br>may perform the same role, but they will each<br>have a unique name.| |Skill level|14, 23, 76|An integer in the range 0 to 100, inclusive.| The programmer has defined a record type to define each character. The record type definition is shown in pseudocode as follows: TYPE CharacterType DECLARE Player : INTEGER DECLARE Role : STRING DECLARE Name : STRING DECLARE SkillLevel : INTEGER ENDTYPE The Player field indicates the player to which the character is assigned (1 to 6). This field value is 0 if the character is not assigned to any player. The programmer has defined a global array to store the character data, as follows: DECLARE Character : ARRAY[1:45] OF CharacterType At the start of the game all record fields are initialised, and all Player fields are set to 0 The programmer has defined a program module as follows: |Module|Description| |---|---| |Count()|• <br>called with two parameters:<br> <br>○<br>an integer representing a player<br> <br>○<br>a string representing a character role<br>• <br>searches the Character array for characters with the given role that are<br>assigned to the given player<br>• <br>counts the number of assigned characters and sums their total skill level<br>• <br>outputs the result of the search if characters with the given role are found,<br>for example:<br> <br> "Player 3 has 4 characters with the role of Teacher<br>and the total skill level is 65"<br>• <br>if no characters with the given role are found, outputs:<br> <br> "No characters with that role are assigned to this<br>player"| ### (a) Complete the pseudocode for module Count(). <span class="part-marks">7 marks</span> PROCEDURE Count(ThisPlayer : INTEGER, ThisRole : STRING) ENDPROCEDURE ### (b) The Character array data has been saved in the text file SaveFile.txt Each line of the file contains one element of the array (one record). <span class="part-marks">7 marks</span> New modules are defined: |Module|Description| |---|---| |Extract()<br>(already written)|• <br>called with two parameters:<br> <br>○<br>a string representing a complete line from the text file<br> <br>○<br>an integer representing a field number (see structure below)<br>• <br>returns a string representing the required field| |Restore()|• <br>opens the text file SaveFile.txt<br>• <br>reads lines from the file and assigns values to each record in the<br>Character array using data from each line of the file| As a reminder, the record structure is repeated here: TYPE CharacterType DECLARE Player : INTEGER //Field number 1 DECLARE Role : STRING //Field number 2 DECLARE Name : STRING //Field number 3 DECLARE SkillLevel : INTEGER //Field number 4 ENDTYPE Write pseudocode for module Restore(). You must use the module Extract(). ### (c) The game can last for several days and users often find that they have to close and rerun the game program many times in order to complete it. <span class="part-marks">2 marks</span> Describe the benefit of using the file SaveFile.txt as described in part (b).
Show mark scheme

8(a) [7 marks]

Example solution PROCEDURE Count(ThisPlayer : INTEGER, ThisRole : STRING) DECLARE Index, Num, Total : INTEGER  Num 0  Total 0  FOR Index 1 TO 45 IF Character[Index].Player = ThisPlayer AND __ Character[Index].Role = ThisRole THEN  Num Num + 1  Total Total + Character[Index].SkillLevel NEXT Index IF Num > 0 THEN OUTPUT "Player ", ThisPlayer, __ " has ", Num, " characters with the role of ", ThisRole, " and the total skill level is ", Total ELSE OUTPUT "No characters with that role are assigned to this player" ENDIF ENDPROCEDURE MP1 Initialisation of local integers for and Num Total MP2 Loop through 45 elements MP3 Attempt to check Player and Role fields in a loop MP4 Correctly compare field with parameter in a loop Player MP5 Correctly compare field with parameter in a loop Role MP6 ... if player and role found, increment and sum Skill Total in a Num loop MP7 Test for any matches after the loop MP8 Both possible OUTPUT statements correctly formed following an attempt at MP6 but outputting one only Max 7 marks

8(b) [7 marks]

Example solution: PROCEDURE Restore() DECLARE Index : INTEGER DECLARE Line : STRING OPENFILE "SaveFile.txt" FOR READ  FOR Index 1 TO 45 READFILE "SaveFile.txt", Line  Character[Index].Player STR_TO_NUM(Extract(Line, 1))  Character[Index].Role Extract(Line, 2)  Character[Index].Name Extract(Line, 3)  Character[Index].Skill STR_TO_NUM(Extract(Line, 4)) NEXT Index CLOSEFILE "SaveFile.txt" ENDPROCEDURE Mark as follows: MP1 Open the file in read mode and subsequently close MP2 Loop through 45 elements MP3 Read a line from the file in a loop MP4 Attempt to use in a loop Extract() MP5 Correct use of for all fields in a loop Extract() MP6 Use of on Player and Skill in a loop STR_TO_NUM() MP7 Completely correct extraction and assignment of all fields in a loop

8(c) [2 marks]

MP1 The array / character data can be saved before the Character program is closed MP2 Allowing the game to continue using the same data / from the point it was saved

Q1
May/Jun 2024 Paper 2 v1

An algorithm is developed in pseudocode before being coded in a programming language.

(a) The following table shows four valid pseudocode assignment statements. 4 marks

Complete the table by giving an a and D. appropriate data type to declare e
Assignment statement Data type
A
LEFT(MyName, 1)
B
Total * 2
C
INT(ItemCost) / 3
D
"Odd OR Even"

(b) Other variables in the program have example values as shown: 4 marks

Variable Value
Sorted False
Tries 9
ID "ZGAC001"

Complete the table by evaluating each expression, using the example values.

Expression Evaluates to
Tries < 10 AND NOT Sorted
Tries MOD 4
TO_LOWER(MID(ID, 3, 1))
LENGTH(ID & "xx") >= Tries
An algorithm is developed in pseudocode before being coded in a programming language. ### (a) The following table shows four valid pseudocode assignment statements. <span class="part-marks">4 marks</span> |Complete the table by giving an a and D.|appropriate data type to declare e| |---|---| |**Assignment statement**|**Data type**| |`A `<br>` LEFT(MyName, 1)`|| |`B `<br>` Total * 2`|| |`C `<br>` INT(ItemCost) / 3`|| |`D `<br>` "Odd OR Even"`|| ### (b) Other variables in the program have example values as shown: <span class="part-marks">4 marks</span> |Variable|Value| |---|---| |`Sorted`|`False`| |`Tries`|`9`| |`ID`|`"ZGAC001"`| Complete the table by evaluating each expression, using the example values. |Expression|Evaluates to| |---|---| |`Tries < 10 AND NOT Sorted`|| |`Tries MOD 4`|| |`TO_LOWER(MID(ID, 3, 1))`|| |`LENGTH(ID & "xx") >= Tries`||
Show mark scheme

1(a) [4 marks]

Assignment statement Data type  CHAR / STRING A LEFT(MyName, 1)  INTEGER / REAL B Total * 2  REAL C INT(ItemCost) / 3  STRING D "Odd OR Even" One mark per row

1(b)

Expression Evaluates to Tries < 10 AND NOT Sorted TRUE Tries MOD 4 1 TO_LOWER(MID(ID, 3, 1)) 'a' // "a" LENGTH(ID & "xx") >= Tries TRUE One mark per row

1(c)(i) [1 mark]

The names do not reflect / indicate the purpose of the variable // the names are not meaningful

1(c)(ii) [1 mark]

They make the program more difficult to understand / debug / maintain

1(c)(iii)

One mark from:  Indentation / use of white space  Capitalisation of keywords  Use of comments  Use of modular programming  Use of local variables Note: max 1 mark

Q3
May/Jun 2024 Paper 2 v2

A factory needs a program to help manage its production of items.

Data will be stored about each item.

The data for each item will be held in a record structure of type Component .

The programmer has started to define the fields that will be needed as shown in the table.

Field Example value Comment
Item_Num 123478 a numeric value used as an array index
Reject FALSE TRUE if this item has been rejected
Stage 'B' a letter to indicate the stage of production
Limit_1 13.5 any value in the range 0 to 100 inclusive
Limit_2 26.4 any value in the range 0 to 100 inclusive

(a) (i) Write pseudocode to declare the record structure for type Component . 4 marks

(ii) A 1D array Item of 2000 elements will store the data for all items. 2 marks

Write pseudocode to declare the Item array.

(b) State three benefits of using an array of records to store the data for all items. 3 marks

1

2

3

A factory needs a program to help manage its production of items. Data will be stored about each item. The data for each item will be held in a record structure of type `Component` . The programmer has started to define the fields that will be needed as shown in the table. |Field|Example value|Comment| |---|---|---| |`Item_Num`|`123478`|a numeric value used as an array index| |`Reject`|`FALSE`|`TRUE` if this item has been rejected| |`Stage`|`'B'`|a letter to indicate the stage of production| |`Limit_1`|`13.5`|any value in the range 0 to 100 inclusive| |`Limit_2`|`26.4`|any value in the range 0 to 100 inclusive| **(a) (i)** Write pseudocode to declare the record structure for type `Component` . <span class="part-marks">4 marks</span> #### (ii) A 1D array `Item` of 2000 elements will store the data for all items. <span class="part-marks">2 marks</span> Write pseudocode to declare the `Item` array. ### (b) State **three** benefits of using an array of records to store the data for all items. <span class="part-marks">3 marks</span> 1 2 3
Show mark scheme

3(a)(i) [2 marks]

Pseudocode: TYPE Component DECLARE Item_Num : INTEGER DECLARE Reject : BOOLEAN DECLARE Stage : CHAR DECLARE Limit_1 : REAL DECLARE Limit_2 : REAL ENDTYPE Mark as follows: 1 One mark for and statements TYPE ENDTYPE 2 One mark for and fields Item_Num Reject 3 One mark for field Stage 4 One mark for Limit fields as REAL DECLARE Item : ARRAY [1:2000] OF Component//

3(a)(ii) [3 marks]

DECLARE Item : ARRAY [2000] OF Component// DECLARE Item : ARRAY [0:1999] OF Component One mark per underlined phrase

3(b) [5 marks]

One mark per point: 1 Allows for iteration / can use a loop to access the records / data items 2 Use of index to directly access a record in the array // Example of simplification of code e.g. use of dot notation Item[1].Stage 3 Simplifies the code / algorithm // Reduces duplication of code // Program easier to write / understand / maintain / test / debug // Data items/record easier to search / sort / manipulate

Q3
May/Jun 2024 Paper 2 v3

A record structure is declared to hold data relating to components being produced in a factory:

TYPE Component DECLARE Item_ID : STRING DECLARE Reject : BOOLEAN DECLARE Weight : REAL ENDTYPE

The factory normally produces a batch (or set) of 1000 components at a time. A global array is declared to store 1000 records for a batch:

DECLARE Batch : ARRAY [1:1000] OF Component

Two global variables contain the minimum and maximum acceptable weight for each component. The values represent an inclusive range and are declared as:

DECLARE Min, Max : REAL

(a) (i) A program uses a variable ThisIndex as the array index to access a record. 3 marks

Write a pseudocode clause to check whether or not the weight of an individual component is within the acceptable range.

(ii) When batches of less than 1000 components are processed, it is necessary to indicate that certain elements in the array are unused. 1 mark

Suggest how an unused array element could be indicated.

(b) A module InRange() will:

  • be called with an integer parameter representing an index value of a record in the Batch array

  • check if the weight of the indexed component is within the acceptable range

  • return TRUE if the weight is in the range and FALSE if it is not .

A module BatchCheck() will:

  • iterate through a batch of 1000 component records

  • call module InRange() to check each individual component record

  • keep a count of the number of components that fail

  • output a suitable warning message and immediately stop if the number of failed components exceeds 5.

A record structure is declared to hold data relating to components being produced in a factory: TYPE Component DECLARE Item_ID : STRING DECLARE Reject : BOOLEAN DECLARE Weight : REAL ENDTYPE The factory normally produces a batch (or set) of 1000 components at a time. A global array is declared to store 1000 records for a batch: DECLARE Batch : ARRAY [1:1000] OF Component Two global variables contain the minimum and maximum acceptable weight for each component. The values represent an inclusive range and are declared as: DECLARE Min, Max : REAL **(a) (i)** A program uses a variable ThisIndex as the array index to access a record. <span class="part-marks">3 marks</span> Write a pseudocode clause to check whether or **not** the weight of an individual component is within the acceptable range. #### (ii) When batches of less than 1000 components are processed, it is necessary to indicate that certain elements in the array are unused. <span class="part-marks">1 mark</span> Suggest how an unused array element could be indicated. ### (b) A module InRange() will: - be called with an integer parameter representing an index value of a record in the Batch array - check if the weight of the indexed component is within the acceptable range - return TRUE if the weight is in the range and FALSE if it is **not** . A module BatchCheck() will: - iterate through a batch of 1000 component records - call module InRange() to check each individual component record - keep a count of the number of components that fail - output a suitable warning message and immediately stop if the number of failed components exceeds 5.
Show mark scheme

3(a)(i)

Example solution using AND IF Batch[ThisIndex].Weight >= Min AND Batch[ThisIndex].Weight <= Max THEN Alternative solution using OR IF Batch[ThisIndex].Weight < Min OR Batch[ThisIndex].Weight > Max THEN Mark as follows:

  1. Reference to Batch[ThisIndex].Weight
  2. A valid check for one boundary
  3. A valid check for other boundary with correct logic operator

3(a)(ii) [5 marks]

One mark for either:  Set the field to an empty string / NULL / invalid value Item_ID  Set to <= 0 / zero Weight

3(b) [6 marks]

ne 1 Zo ne 2 Zo ne 3 Zo ne 4 Zo ne 5 Zo One mark per zone

Q7
Oct/Nov 2023 Paper 2 v3

A structure chart shows the modular structure of a program:

(a) Explain the meaning of the curved arrow symbol which begins and ends at Module-A(). 2 marks

(b) The structure chart shows that Sub-9() is a function.

A Boolean value is returned by Sub-9() for processing by Module-A().

The original parameter RA is of type integer and RB is of type string.

A record type MyType will be defined with three fields to store the values passed between the two modules.

(i) Write pseudocode to define MyType . 3 marks

(ii) The design is modified and Sub-9() is changed to a procedure. 2 marks

The procedure will be called with a single parameter of type MyType .

Write the pseudocode header for procedure Sub-9() .

A structure chart shows the modular structure of a program: ![](../images/w23_23_q7_fig1.png) ### (a) Explain the meaning of the curved arrow symbol which begins and ends at Module-A(). <span class="part-marks">2 marks</span> ### (b) The structure chart shows that Sub-9() is a function. A Boolean value is returned by Sub-9() for processing by Module-A(). The original parameter RA is of type integer and RB is of type string. A record type `MyType` will be defined with three fields to store the values passed between the two modules. #### (i) Write pseudocode to define `MyType` . <span class="part-marks">3 marks</span> #### (ii) The design is modified and Sub-9() is changed to a procedure. <span class="part-marks">2 marks</span> The procedure will be called with a single parameter of type `MyType` . Write the pseudocode header for procedure `Sub-9()` .
Show mark scheme

7(a) [2 marks]

MP1 iteration / looping MP2 naming all four modules correctly in the correct sequence // e.g. repeatedly calls then then Module-A Sub-Y1, SubY2 Sub-9 TYPE MyType

7(b)(i) [3 marks]

DECLARE RA : INTEGER DECLARE RB : STRING DECLARE RC : BOOLEAN ENDTYPE MP1 TYPE MyType... ENDTYPE MP2 as integer and as string RA RB3 MP3 as Boolean RC PROCEDURE Sub-9(BYREF Param : MyType)

7(b)(ii) [2 marks]

MP 1 One mark for BYREF MP 2 One mark for the rest of the statement PROCEDURE ReceiveFile(FileName : STRING)

Q1
May/Jun 2023 Paper 2 v3

The following pseudocode represents part of the algorithm for a program.

Line numbers are for reference only.

    10  DECLARE Sheet4 : ARRAY[1:2, 1:50] OF INTEGER
    …

    100 FOR PCount  0 TO 49
    101   Sheet4[1, PCount]  0
    102   Sheet4[2, PCount]  47
    103 NEXT PCount

(a) The pseudocode contains references to an array. 3 marks

Complete the table by writing the answer for each row.

Answer
The dimension of the array
The name of the variable used as an array index
The number of elements in the array

(b) The pseudocode contains two errors. One error is that variable PCount has not been declared. 2 marks

Identify the other error and state the line number where it occurs.

Error

Line number

(c) The pseudocode does not include a declaration for PCount . 1 mark

State the data type that should be used in the declaration.

The following pseudocode represents part of the algorithm for a program. Line numbers are for reference only. ``` 10 DECLARE Sheet4 : ARRAY[1:2, 1:50] OF INTEGER … 100 FOR PCount 0 TO 49 101 Sheet4[1, PCount] 0 102 Sheet4[2, PCount] 47 103 NEXT PCount ``` ### (a) The pseudocode contains references to an array. <span class="part-marks">3 marks</span> Complete the table by writing the answer for each row. ||Answer| |---|---| |The dimension of the array|| |The name of the variable used as an array index|| |The number of elements in the array|| ### (b) The pseudocode contains two errors. One error is that variable `PCount` has not been declared. <span class="part-marks">2 marks</span> Identify the **other** error **and** state the line number where it occurs. Error Line number ### (c) The pseudocode does not include a declaration for `PCount` . <span class="part-marks">1 mark</span> State the data type that should be used in the declaration.
Show mark scheme

1(a) [3 marks]

2 The dimension of the array PCount The name of the variable used as an array index 100 The number of elements in the array

1(b) [2 marks]

One mark per point:  The (second dimension/index of the) array is declared from 1 to 50 but the loop runs from 0 to 49  Line number: 10 / 100 / 101 / 102

1(c) [1 mark]

Integer

1(d) [4 marks]

One mark for each of rows 2 - 5 Pseudocode statement Input Process Output INPUT MyChoice  OUTPUT FirstName & LastName   WRITEFILE OutputFile, TextLine  READFILE MyFile, TextLine    Result SQRT(NextNum)

Q2
May/Jun 2023 Paper 2 v3

A program stores a date of birth for a student using a variable, MyDOB, of type DATE .

(a) MyDOB has been assigned a valid value corresponding to Kevin’s date of birth.

Complete the pseudocode statement to test whether Kevin was born on a Thursday.

IF ______ THEN [2]

(b) A function CheckDate() will take three integer parameters representing a day, month and year of a given date.

The function will validate the date of birth for a student that the parameters passed to it represent. For a date to be valid, a student must be at least 18 in year 2020.

(i) Two of the parameter values can be checked without reference to the third parameter. 2 marks

Describe these two checks.

Check 1

Check 2

(ii) Several values of the parameter representing the day can only be checked completely by referring to the value of one other parameter. 2 marks

Describe this check.

A program stores a date of birth for a student using a variable, `MyDOB`, of type `DATE` . ### (a) `MyDOB` has been assigned a valid value corresponding to Kevin’s date of birth. Complete the pseudocode statement to test whether Kevin was born on a Thursday. `IF` ______ `THEN` [2] ### (b) A function `CheckDate()` will take three integer parameters representing a day, month and year of a given date. The function will validate the date of birth for a student that the parameters passed to it represent. For a date to be valid, a student must be at least 18 in year 2020. #### (i) Two of the parameter values can be checked without reference to the third parameter. <span class="part-marks">2 marks</span> Describe these **two** checks. Check 1 Check 2 #### (ii) Several values of the parameter representing the day can only be checked completely by referring to the value of **one other** parameter. <span class="part-marks">2 marks</span> Describe this check.
Show mark scheme

2(a) [2 marks]

One mark for each underlined part IF DAYINDEX(MyDOB) = 5 THEN

2(b)(i) [2 marks]

MP1 Value for month is between 1 and 12 (inclusive) MP2 Value of year is <= 2002

2(b)(ii)

MP1 Reference to month and day MP2 Clear description for a check that the day number matches with a relevant month (Either day matches with month // month matches with day)

Q1
Oct/Nov 2022 Paper 2 v1

(a) An algorithm includes a number of complex calculations. A programmer is writing a program to implement the algorithm and decides to use library routines to provide part of the solution. 3 marks

State three possible benefits of using library routines in the development of the program.

1

2

3

(b) The following pseudocode is part of a program that stores names and test marks for use in other parts of the program.

    DECLARE Name1, Name2, Name3 : STRING
    DECLARE Mark1, Mark2, Mark3 : INTEGER
    INPUT Name1
    INPUT Mark1
    INPUT Name2
    INPUT Mark2
    INPUT Name3
    INPUT Mark3

(i) The pseudocode needs to be changed to allow for data to be stored for up to 30 students. 3 marks

Explain why it would be good practice to use arrays to store the data.

### (a) An algorithm includes a number of complex calculations. A programmer is writing a program to implement the algorithm and decides to use library routines to provide part of the solution. <span class="part-marks">3 marks</span> State **three** possible benefits of using library routines in the development of the program. 1 2 3 ### (b) The following pseudocode is part of a program that stores names and test marks for use in other parts of the program. ``` DECLARE Name1, Name2, Name3 : STRING DECLARE Mark1, Mark2, Mark3 : INTEGER INPUT Name1 INPUT Mark1 INPUT Name2 INPUT Mark2 INPUT Name3 INPUT Mark3 ``` #### (i) The pseudocode needs to be changed to allow for data to be stored for up to 30 students. <span class="part-marks">3 marks</span> Explain why it would be good practice to use arrays to store the data.
Show mark scheme

1(a) [3 marks]

One mark per point: 1 They are tried and tested so free from errors 2 They perform a function that you may not be able to program yourself (for example encryption ) 3 They are readily available / speed up development time

1(b)(i) [3 marks]

One mark per point: 1 Algorithm to process / search / organise the data is easier to implement // Values may be accessed via a loop-controlled variable / iterated through using index 2 Makes the program easier to design / code / test / understand 3 Multiple instances referenced via a single identifier / so fewer identifiers needed // Easier to amend the program when the number of students increases

1(b)(ii) [2 marks]

One mark per point: Purpose : It identifies / references an individual array element // provides the index to the array Data type : Integer

1(c) [4 marks]

One mark per row: Statement Error   Should be "=" not IF EMPTY "" THEN  Parameter should be a string (or Status IS_NUM(-23.4) char) // should not be a real  NO ERROR X STR_TO_NUM("37") + 5  Wrong operator – should be & or Y STR_TO_NUM("37" + "5") Parameter is not a string

Q3
Oct/Nov 2022 Paper 2 v2

A stack is used in a program to store string data which needs to be accessed in several modules.

(a) A stack is an example of an Abstract Data Type (ADT). 3 marks

Identify one other example of an ADT and describe its main features.

Example

Features

(b) Explain how the stack can be implemented using an array. 5 marks

A stack is used in a program to store string data which needs to be accessed in several modules. ### (a) A stack is an example of an Abstract Data Type (ADT). <span class="part-marks">3 marks</span> Identify **one** **other** example of an ADT **and** describe its main features. Example Features ### (b) Explain how the stack can be implemented using an array. <span class="part-marks">5 marks</span>
Show mark scheme

3(a) [3 marks]

One mark for name, Max two for features ( Max 3 in total ) Name: Queue Features: 1 Each queue element contains one data item 2 A Pointer to the front / start of the queue 3 A Pointer to the back / end of the queue 4 Data is added at back / end and removed from front / start // works on a FIFO basis 5 May be circular ALTERNATIVE: Name: Linked List Features: 1 Each node contains data and a pointer to the next node 2 A Pointer to the start of the list 3 Last node in the list has a null pointer 4 Data may be added / removed by manipulating pointers (not moving data) 5 Nodes are traversed in a specific sequence 6 Unused nodes are stored on a free list // a free-list pointer to the Free List

3(b) [5 marks]

One mark per point ( Max 5 ): 1 Declare a (1D) array of data type STRING 2 The number of elements in that array corresponds to the size of the required stack 3 Declare an integer / variable for StackPointer 4. Declare an integer / variable for the size of the stack // for the max value of StackPointer 5 Use the as an index to the array StackPointer 6 Pointers and variables initialised to indicate empty stack 7 Store each item on the stack as one array element / Each stack item maps to one array element 8 Attempt to describe Push and Pop operations 9 Push and Pop routines need to check for full or empty conditions

3(c) [5 marks]

One mark for each: 1 Data 'After Group 1' (as shown, including blank cells) 2 Data 'After Group 2' (as shown, including blank cells) 3 Data 'After Group 3' (as shown, including blank cells) 4 SP 'After Group 1' pointing to location 955 5 Final two SPs pointing to locations 952 and 954

Q3
Oct/Nov 2022 Paper 2 v3

An algorithm is needed to process a sequence of numbers. Numbers may be positive or negative and may be integer or decimal.

The algorithm will:

  • prompt and input one number at a time until the value zero is input

  • sum the negative numbers

  • sum the positive numbers

  • when zero is input, output the two sum values and then end.

Describe the algorithm needed. Do not include pseudocode statements in your answer. 5 marks

An algorithm is needed to process a sequence of numbers. Numbers may be positive or negative and may be integer or decimal. The algorithm will: - prompt and input one number at a time until the value zero is input - sum the negative numbers - sum the positive numbers - when zero is input, output the two sum values and then end. Describe the algorithm needed. Do **not** include pseudocode statements in your answer. <span class="part-marks">5 marks</span>
Show mark scheme

3 [5 marks]

One mark per point, for example: 1 Declare two ( variables for the two sum values AND initialise both REAL) to zero 2 Prompt AND Input a number 3 If number greater than zero add to positive sum and If number less than zero add to negative sum 4 Repeat from step 2 if number not zero 5 After loop the Output and SumPos SumNeg

Q1
May/Jun 2022 Paper 2 v1

(a) A programmer draws a program flowchart to show the sequence of steps required to solve a problem. 1 mark

Give the technical term for a sequence of steps that describe how to solve a problem.

(b) The table lists some of the variables used in a program.

(i) Complete the table by writing the most appropriate data type for each variable. 4 marks 2 marks

Variable Use of variable Data type
Temp Stores the average temperature
PetName Stores the name of my pet
MyDOB To calculate the number of days until my next
birthday
LightOn Stores state of light; light is only on or off

(ii) One of the names used for a variable in the table in part 1(b)(i) is not an example of good practice. 4 marks

Identify the variable and give a reason why it is not good practice to use that name.

Variable

Reason

Complete the table by evaluating each expression.
Expression Evaluation
INT((31 / 3) + 1)
MID(TO_UPPER("Version"), 4, 2)
TRUE AND (NOT FALSE)
NUM_TO_STR(27 MOD 3)
### (a) A programmer draws a program flowchart to show the sequence of steps required to solve a problem. <span class="part-marks">1 mark</span> Give the technical term for a sequence of steps that describe how to solve a problem. ### (b) The table lists some of the variables used in a program. #### (i) Complete the table by writing the most appropriate data type for each variable. <span class="part-marks">4 marks</span> <span class="part-marks">2 marks</span> |Variable|Use of variable|Data type| |---|---|---| |`Temp`|Stores the average temperature|| |`PetName`|Stores the name of my pet|| |`MyDOB`|To calculate the number of days until my next<br>birthday|| |`LightOn`|Stores state of light; light is only on or off|| #### (ii) One of the names used for a variable in the table in part **1(b)(i)** is not an example of good practice. <span class="part-marks">4 marks</span> Identify the variable and give a reason why it is **not** good practice to use that name. Variable Reason |Complete the table by evaluating each expression.|| |---|---| |**Expression**|**Evaluation**| |`INT((31 / 3) + 1)`|| |`MID(TO_UPPER("Version"), 4, 2)`|| |`TRUE AND (NOT FALSE)`|| |`NUM_TO_STR(27 MOD 3)`||
Show mark scheme

1(a) [4 marks]

An algorithm

1(b)(i) [2 marks]

Variable Use of variable Data type Temp Stores the average temperature REAL PetName Stores the name of my pet STRING MyDOB To calculate how many days until my DATE next birthday LightOn Stores state of light; light is only on or off BOOLEAN One mark for each data type

1(b)(ii)

One mark for variable name, and one for reason Variable: Temp Reason: Name does not indicate what the variable is used for

1(c) [4 marks]

Expression Evaluation INT((31 / 3) + 1) 11 MID(TO_UPPER("Version"), 4, 2) "SI" TRUE AND (NOT FALSE) TRUE NUM_TO_STR(27 MOD 3) "0" One mark per row

Q5
May/Jun 2022 Paper 2 v3

A program will store attendance data about each employee of a company.

The data will be held in a reco shown: ord structure of type Employee e. The fields that will be needed are as
Field Typical value Comment
EmployeeNumber 123 A numeric value starting from 1
Name "Smith,Eric" Format: ','
Department "1B" May contain letters and numbers
Born 13/02/2006 Must not be before 04/02/1957
Attendance 97.40 Represents a percentage

(a) (i) Write pseudocode to declare the record structure for type Employee . 4 marks

(ii) A 1D array Staff containing 500 elements will be used to store the employee records. 2 marks

Write pseudocode to declare the Staff array.

(b) There may be more records in the array than there are employees in the company. In this case, some records of the array will be unused.

(i) State why it is good practice to have a standard way to indicate unused array elements. 1 mark

(ii) Give one way of indicating an unused record in the Staff array. 1 mark

A program will store attendance data about each employee of a company. |The data will be held in a reco shown:|ord structure of type Employee|e. The fields that will be needed are as| |---|---|---| |**Field**|**Typical value**|**Comment**| |`EmployeeNumber`|`123`|A numeric value starting from 1| |`Name`|`"Smith,Eric"`|Format: <last name>','<first name>| |`Department`|`"1B"`|May contain letters and numbers| |`Born`|`13/02/2006`|Must not be before 04/02/1957| |`Attendance`|`97.40`|Represents a percentage| **(a) (i)** Write pseudocode to declare the record structure for type `Employee` . <span class="part-marks">4 marks</span> #### (ii) A 1D array `Staff` containing 500 elements will be used to store the employee records. <span class="part-marks">2 marks</span> Write pseudocode to declare the `Staff` array. ### (b) There may be more records in the array than there are employees in the company. In this case, some records of the array will be unused. #### (i) State why it is good practice to have a standard way to indicate unused array elements. <span class="part-marks">1 mark</span> #### (ii) Give **one** way of indicating an unused record in the `Staff` array. <span class="part-marks">1 mark</span>
Show mark scheme

5(a)(i)

DECLARE EmployeeNumber : INTEGER DECLARE Name : STRING DECLARE Department : STRING DECLARE Born : DATE DECLARE Attendance : REAL ENDTYPE One mark for each: 1. and TYPE Employee ENDTYPE 2. and and Fields: EmployeeNumber Name Department 3. Field: Born 4. Field: Attendance DECLARE Staff : ARRAY [1:500] OF Employee

5(a)(ii) [2 marks]

One mark per underlined phrase

5(b)(i) [1 mark]

Example answers to Max 1 :  So that unused elements may be recognised when processing / searching  Otherwise the element may contain old / unexpected data

5(b)(ii) [1 mark]

Use of any 'impossible' field value, for example:  An field. e.g. < 1 EmployeeNumber  An empty string / impossible string e.g. "EMPTY" for name or department  DOB a long time ago...  Zero / Negative value for attendance PROCEDURE Absentees()

5(c) [6 marks]

DECLARE Index : INTEGER  FOR Index 1 TO 500 IF Staff[Index].EmployeeNumber <> −1 THEN // not empty IF Staff[Index].Attendance <= 90 THEN OUTPUT Staff[Index].EmployeeNumber OUTPUT Staff[Index].Name ENDIF ENDIF NEXT Index ENDPROCEDURE Marks as follows to Max 4 : 1 Procedure heading and ending and declaration of loop counter 2 loop through 500 elements 3 attempt to skip unused element 4 test in a loop <= 90 Staff[Index].Attendance 5 if so, output and fields in a loop Name EmployeeNumber FUNCTION Factorial(ThisNum : INTEGER) RETURNS INTEGER

Q1
Oct/Nov 2021 Paper 2 v1

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 mark

(ii) Identify and describe one other type of error that the program may contain. 2 marks

Type of error

Description

(b) Complete the following table by giving the appropriate data type in each case. 4 marks

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
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”. <span class="part-marks">1 mark</span> #### (ii) Identify **and** describe **one** other type of error that the program may contain. <span class="part-marks">2 marks</span> Type of error Description ### (b) Complete the following table by giving the appropriate data type in each case. <span class="part-marks">4 marks</span> |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||
Show mark scheme

1(a)(i) [2 marks]

One from: 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) [4 marks]

One mark for type plus one for corresponding description 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) [3 marks]

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)

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) [2 marks]

One mark for technique and one for benefit, Max 1 mark for 'Benefit' 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) [6 marks]

Answers include: Destination / arrival airport • Arrival time / flight duration • Date of flight • Seat number • Seat availability • Max 2 marks

Q3
Oct/Nov 2021 Paper 2 v2

A programmer is writing a program to help manage clubs in a school.

Data will be stored about each student in the school and each student may join up to three clubs.

The data will be held in a record structure of type Student .

The program table. mmer has started to define the fie elds that will be needed as shown in the followi
Field Typical value Comment
StudentID "CF1234" Unique to each student
Email "Carmen47@xyzmail.com" Contains letters, numbers and certain symbols
Club_1 1 Any value in the range 1 to 99 inclusive
Club_2 14 Any value in the range 1 to 99 inclusive
Club_3 27 Any value in the range 1 to 99 inclusive

(a) (i) Write pseudocode to declare the record structure for type Student . 3 marks

(ii) A 1D array Membership containing 3000 elements will be used to store the student data. 2 marks

Write pseudocode to declare the Membership array.

(iii) Some of the elements of the array will be unused. 1 mark

Give an appropriate way of indicating an unused array element.

(iv) Some students are members of less than three clubs. 1 mark

State one way of indicating an unused club field.

(b) A procedure GetIDs() will: 7 marks

  • prompt and input the number of a club

  • output the StudentID of all the students who are members of that club

  • output a count of all students in the given club.

Write pseudocode for the procedure GetIDs() .

A programmer is writing a program to help manage clubs in a school. Data will be stored about each student in the school and each student may join up to three clubs. The data will be held in a record structure of type `Student` . |The program table.|mmer has started to define the fie|elds that will be needed as shown in the followi| |---|---|---| |**Field**|**Typical value**|**Comment**| |`StudentID`|`"CF1234"`|Unique to each student| |`Email`|`"Carmen47@xyzmail.com"`|Contains letters, numbers and certain symbols| |`Club_1`|`1`|Any value in the range 1 to 99 inclusive| |`Club_2`|`14`|Any value in the range 1 to 99 inclusive| |`Club_3`|`27`|Any value in the range 1 to 99 inclusive| **(a) (i)** Write pseudocode to declare the record structure for type `Student` . <span class="part-marks">3 marks</span> #### (ii) A 1D array `Membership` containing 3000 elements will be used to store the student data. <span class="part-marks">2 marks</span> Write pseudocode to declare the `Membership` array. #### (iii) Some of the elements of the array will be unused. <span class="part-marks">1 mark</span> Give an **appropriate** way of indicating an unused array element. #### (iv) Some students are members of less than three clubs. <span class="part-marks">1 mark</span> State **one** way of indicating an unused club field. ### (b) A procedure `GetIDs()` will: <span class="part-marks">7 marks</span> - prompt and input the number of a club - output the `StudentID` of all the students who are members of that club - output a count of all students in the given club. Write pseudocode for the procedure `GetIDs()` .
Show mark scheme

3(a)(i) [2 marks]

Pseudocode: TYPE Student DECLARE StudentID : STRING DECLARE Email : STRING DECLARE Club_1 : INTEGER DECLARE Club_2 : INTEGER DECLARE Club_3 : INTEGER ENDTYPE Mark as follows: One mark for and • TYPE ENDTYPE One mark for and fields as • StudentID Email STRING One mark for all Club fields as • INTEGER

3(a)(ii)

DECLARE Membership : ARRAY [1:3000] OF Student One mark per underlined phrase

3(a)(iii) [1 mark]

One mark for any one of: Assign a value (of the corrrect data type) outside the normal range to one • of the fields Assign an empty string to the field / field • StudentID Email or value out of range to any club field •

3(a)(iv) [7 marks]

A number outside the range 1 to 99

3(b)

PROCEDURE GetIDs() DECLARE Index : INTEGER DECLARE ThisClub, Count : INTEGER OUTPUT "Please Input Club Number: " INPUT ThisClub ← Count 0 ← FOR Index 1 TO 3000 IF Membership[Index].Club_1 = ThisClub OR __ Membership[Index].Club_2 = ThisClub OR __ Membership[Index].Club_3 = ThisClub THEN ← Count Count + 1 OUTPUT Membership[Index].StudentID ENDIF NEXT Index OUTPUT "There are ", Count, " Students in the club" ENDPROCEDURE Mark as follows: 1 Declare and initialise Count 2 Prompt and Input club number before the loop 3 Loop through 3000 elements 4 Compare one club field with number input 5 Compare all fields with number input Club 6 If number found, of field and increment OUTPUT StudentID Count 7 Final of outside the loop OUTPUT Count Note: Max 6 if procedure heading and ending missing or incorrect (but allow array as parameter)

Q1
Oct/Nov 2021 Paper 2 v3

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 mark

(ii) Identify and describe one other type of error that the program may contain. 2 marks

Type of error

Description

(b) Complete the following table by giving the appropriate data type in each case. 4 marks

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
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”. <span class="part-marks">1 mark</span> #### (ii) Identify **and** describe **one** other type of error that the program may contain. <span class="part-marks">2 marks</span> Type of error Description ### (b) Complete the following table by giving the appropriate data type in each case. <span class="part-marks">4 marks</span> |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||
Show mark scheme

1(a)(i) [2 marks]

One from: 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) [4 marks]

One mark for type plus one for corresponding description 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) [3 marks]

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)

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) [2 marks]

One mark for technique and one for benefit, Max 1 mark for 'Benefit' 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) [6 marks]

Answers include: Destination / arrival airport • Arrival time / flight duration • Date of flight • Seat number • Seat availability • Max 2 marks

Q1
May/Jun 2021 Paper 2 v1

(a) A program is being developed to help manage the membership of a football club. 4 marks

Complete the following identifier table.

Example
value
Explanation Variable name Data type
"Wong" The preferred name of the member
joining the football club
FALSE A value to indicate whether an
existing member of the club lives at
the same address
19/02/1983 When the member joined the football
club
1345 The number of points a member has
earned. Members of the club earn
points for different activities.

(b) Each pseudocode statement in the following table may contain an error due to the incorrect use of the function or operator. 5 marks

Describe 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
Result
2 & 4
SubString
MID("pseudocode", 4, 1)
IF x = 3 OR 4 THEN
Result
Status AND INT(x/2)
Message
"Done" + LENGTH(MyString)
### (a) A program is being developed to help manage the membership of a football club. <span class="part-marks">4 marks</span> Complete the following identifier table. |Example<br>value|Explanation|Variable name|Data type| |---|---|---|---| |`"Wong"`|The preferred name of the member<br>joining the football club||| |`FALSE`|A value to indicate whether an<br>existing member of the club lives at<br>the same address||| |`19/02/1983`|When the member joined the football<br>club||| |`1345`|The number of points a member has<br>earned. Members of the club earn<br>points for different activities.||| ### (b) Each pseudocode statement in the following table may contain an error due to the incorrect use of the function or operator. <span class="part-marks">5 marks</span> Describe 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| |---|---| |`Result`<br>` 2 & 4`|| |`SubString`<br>` MID("pseudocode", 4, 1)`|| |`IF x = 3 OR 4 THEN`|| |`Result`<br>` Status AND INT(x/2)`|| |`Message`<br>` "Done" + LENGTH(MyString)`||
Show mark scheme

1(a)

Example Explanation Variable name Data type value The preferred name of the "Wong" MemberName STRING member joining the football club A value to indicate FALSE FamilyMember BOOLEAN whether an existing member of the club lives at the same address When the member joined 19/02/1983 StartDate DATE the football club The number of points a 1345 Points INTEGER member has earned. Members of the club earn points for different activities. One mark for each appropriate variable name plus data type

1(b) [3 marks]

Statement Error Should be arithmetic operator (not &) // 2 and 4 ← Result 2 & 4 should be CHAR / STRING NO ERROR ← SubString MID("pseudocode", 4, 1) Not Boolean values / incorrect operator // IF x = 3 OR 4 THEN Condition incorrect doesn't evaluate INT(X/2) to a boolean value / ← Result Status AND INT(X/2) incorrect operator Can’t add string to number / ← Message "Done" + LENGTH(MyString) is not a number "Done" One mark for each row

1(c) [5 marks]

Structure: Record • Justification: Allows different data types • to be stored under one identifier • Mark as follows: One mark for Structure Two marks for justification. Alternative Two (1D) arrays • One of string, one of integer • Where same index links the name with the score •

Q1
May/Jun 2021 Paper 2 v3

(a) A program is being developed to help manage the membership of a football club. 4 marks

Complete the following identifier table.

Example
value
Explanation Variable name Data type
"Wong" The preferred name of the member
joining the football club
FALSE A value to indicate whether an
existing member of the club lives at
the same address
19/02/1983 When the member joined the football
club
1345 The number of points a member has
earned. Members of the club earn
points for different activities.

(b) Each pseudocode statement in the following table may contain an error due to the incorrect use of the function or operator. 5 marks

Describe 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
Result
2 & 4
SubString
MID("pseudocode", 4, 1)
IF x = 3 OR 4 THEN
Result
Status AND INT(x/2)
Message
"Done" + LENGTH(MyString)
### (a) A program is being developed to help manage the membership of a football club. <span class="part-marks">4 marks</span> Complete the following identifier table. |Example<br>value|Explanation|Variable name|Data type| |---|---|---|---| |`"Wong"`|The preferred name of the member<br>joining the football club||| |`FALSE`|A value to indicate whether an<br>existing member of the club lives at<br>the same address||| |`19/02/1983`|When the member joined the football<br>club||| |`1345`|The number of points a member has<br>earned. Members of the club earn<br>points for different activities.||| ### (b) Each pseudocode statement in the following table may contain an error due to the incorrect use of the function or operator. <span class="part-marks">5 marks</span> Describe 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| |---|---| |`Result`<br>` 2 & 4`|| |`SubString`<br>` MID("pseudocode", 4, 1)`|| |`IF x = 3 OR 4 THEN`|| |`Result`<br>` Status AND INT(x/2)`|| |`Message`<br>` "Done" + LENGTH(MyString)`||
Show mark scheme

1(a)

Example Explanation Variable name Data type value The preferred name of the "Wong" MemberName STRING member joining the football club A value to indicate FALSE FamilyMember BOOLEAN whether an existing member of the club lives at the same address When the member joined 19/02/1983 StartDate DATE the football club The number of points a 1345 Points INTEGER member has earned. Members of the club earn points for different activities. One mark for each appropriate variable name plus data type

1(b) [3 marks]

Statement Error Should be arithmetic operator (not &) // 2 and 4 ← Result 2 & 4 should be CHAR / STRING NO ERROR ← SubString MID("pseudocode", 4, 1) Not Boolean values / incorrect operator // IF x = 3 OR 4 THEN Condition incorrect doesn't evaluate INT(X/2) to a boolean value / ← Result Status AND INT(X/2) incorrect operator Can’t add string to number / ← Message "Done" + LENGTH(MyString) is not a number "Done" One mark for each row

1(c) [5 marks]

Structure: Record • Justification: Allows different data types • to be stored under one identifier • Mark as follows: One mark for Structure Two marks for justification. Alternative Two (1D) arrays • One of string, one of integer • Where same index links the name with the score •