Note AcademyNote Academy

Computer Science (AS & A Level) · Oct / Nov 2024 · Paper 22 · Question 6

9618

As printed in the paper

The question as text

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 follows: 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."

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme
  • 6(a)[7]

  • 6(b)[2]

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.