Skip to main content
A-LevelComputer ScienceFurther programming9618/21 · May/June 2025 · Q718 Marks

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.

  1. (a)Write pseudocode for module CustomerOrder()[6]
  2. (b)(i)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 | Write pseudocode for module AddNewCustomers() Assume that there is at least one customer already in the loyalty scheme.[8]
  3. (b)(ii)The requirements for AddNewCustomers() are changed. There may be no existing customers in the loyalty scheme. Explain the changes that will need to be made to the module AddNewCustomers()[4]

Mark scheme

Marking points from the official mark scheme (May/June 2025). The mark or mark type is shown in brackets.

  1. [1] Function header and ending and parameters and return type
  2. [1] Number of coffees ordered added to points
  3. [1] Correct calculation of one free coffee
  4. [1] Attempted calculation of multiple free coffees and reduced NewPoints
  5. [1] Output number of free drinks with suitable message
  6. [1] Return of NewPoints
  7. [1] All variables used are declared using the correct type including a string and an integer
  8. [1] Open file in read mode and close (before opening in append mode)
  9. [1] Conditional loop with EOF ("Loyalty.txt")
  10. [1] Read Line from file // Count number of records in the file
  11. [1] Open the file in append mode and subsequently close
  12. [1] Extract CustomerID from Line and convert to integer // use count from MP4 to generate last CustomerID stored
  13. [1] A (count controlled) loop for the number of customers to add
  14. [1] Increment CustomerID and output the new CustomerID in loop
  15. [1] Create string for new CustomerID and write to file in loop
  16. [1] Check if the text file loyalty.txt exists / is empty
  17. [1] If file does not exist it must be created (using write mode)
  18. [1] If the file has to be created / is empty then set the first CustomerID to 100001
  19. [1] Write "100001,0" to loyalty.txt (using write mode)
  20. [1] For all but the first customer (to be added to the empty file) use the existing code / module

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Further programming, A-Level Computer Science (syllabus 9618). Structured question, 18 marks.
Source
A-Level Computer Science, May/June 2025 Paper 2 Variant 1, question 7.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep