Skip to main content
A-LevelComputer ScienceProgramming9618/22 · Oct/Nov 2024 · Q69 Marks

A shop sells sandwiches and snacks. The owner chooses a 'daily special' sandwich which is displayed on a board outside the shop. Each 'daily special' has two different fillings and is made with one type of bread. The owner wants a program to randomly choose the 'daily special' sandwich. The program designer decides to store the possible sandwich fillings in a 1D array of type string. The array is declared in pseudocode as shown: DECLARE Filling : ARRAY [1:35] OF STRING Each element contains the name of one filling. An example of the first five elements is as follows: | Index | Element value | |-------|-----------------| | 1 | "Cheese" | | 2 | "Onion" | | 3 | "Salmon" | | 4 | "Anchovies" | | 5 | "Peanut Butter" | A second 1D array stores the possible bread used: DECLARE Bread : ARRAY [1:10] OF STRING Each element contains the name of one type of bread. An example of the first three elements is as follows: | Index | Element value | |-------|---------------| | 1 | "White" | | 2 | "Brown" | | 3 | "Pitta" | Both arrays may contain unused elements. The value of these will be an empty string and they may occur anywhere in each array. A procedure Special() will output a message giving the 'daily special' sandwich made from two randomly selected different fillings and one randomly selected bread. Unused array elements must not be used when creating the 'daily special' sandwich. Using the above examples, the output could be: "The daily special is Cheese and Onion on Brown bread."

  1. (a)Complete the pseudocode for the procedure Special(). Assume that both arrays are global. PROCEDURE Special() ENDPROCEDURE[7]
  2. (b)The owner decides that some combinations of fillings do not go well together. For example, anchovies and peanut butter. Describe how the design could be changed to prevent certain combinations being selected.[2]

Mark scheme

Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.

  1. [1] PROCEDURE Special()
  2. [1] DECLARE Index : INTEGER
  3. [1] DECLARE Filling1, Filling2 : STRING
  4. [1] REPEAT ... UNTIL Filling[Index] <> ""
  5. [1] Index ← INT(RAND(35)) + 1
  6. [1] Filling1 ← Filling[Index]
  7. [1] REPEAT ... UNTIL Filling[Index] <> "" AND Filling1 <> Filling[Index]
  8. [1] Index ← INT(RAND(35)) + 1
  9. [1] Filling2 ← Filling[Index]
  10. [1] REPEAT ... UNTIL Bread[Index] <> ""
  11. [1] Index ← INT(RAND(10)) + 1
  12. [1] OUTPUT "The daily special is ", Filling1, " and ", Filling2, " on ", Bread[Index], " bread."
  13. [1] ENDPROCEDURE
  14. [1] For each filling, create a list of acceptable / incompatible fillings/indexes
  15. [1] When selecting the second filling, (as well as checking for an unused element) check that the filling / index is / is not on the list
  16. [1] ALTERNATIVE: Create a list of 'good' combinations
  17. [1] Randomly select from this list

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
Programming, A-Level Computer Science (syllabus 9618). Structured question, 9 marks.
Source
A-Level Computer Science, Oct/Nov 2024 Paper 2 Variant 2, question 6.

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