Skip to main content
A-LevelComputer ScienceProgramming9618/21 · Oct/Nov 2021 · Q510 Marks

The following data items will be recorded each time a student successfully logs on to the school network: Data item Example data Student ID "CJL404" Host ID "Lib01" Time and date "08:30, June 01, 2021" The Student ID is six characters long. The other two data items are of variable length. A single string will be formed by concatenating the three data items. A separator character will need to be inserted between items two and three. For example: "CJL404Lib01<separator>08:30, June 01, 2021" Each string represents one log entry. A programmer decides to store the concatenated strings in a 1D array LogArray that contains 2000 elements. Unused array elements will contain an empty string.

  1. (a)Suggest a suitable separator character and give a reason for your choice. Character Reason[2]
  2. (b)The choice of data structure was made during one stage of the program development life cycle. Identify this stage.[1]
  3. (c)A function LogEvents() will: • take a Student ID as a parameter • for each element in the array that matches the Student ID parameter: o add the value of the array element to the existing text file LogFile o assign an empty string to the array element • count the number of lines added to the file • return this count. Write pseudocode for the function LogEvents().[7]

Mark scheme

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

  1. [2] One mark for the character and one for the corresponding reason.
  2. • Character: Any except alphabetic, numeric, ',' ':' or space
  3. • Reason: character doesn't occur in data to be recorded
  4. [1] Design
  5. [7] FUNCTION LogEvents(StudentID : STRING) RETURNS INTEGER
  6. DECLARE FileData : STRING
  7. DECLARE Index, Count : INTEGER
  8. CONSTANT LogFile = "LogFile"
  9. Count ← 0
  10. OPENFILE LogFile FOR APPEND
  11. FOR Index ← 1 TO 2000
  12. FileData ← LogArray[Index]
  13. IF LEFT(FileData, 6) = StudentID THEN
  14. WRITEFILE (LogFile, FileData) //brackets optional
  15. Count ← Count + 1
  16. LogArray[Index] ← "" // clear the element
  17. ENDIF
  18. NEXT Index
  19. CLOSEFILE LogFile
  20. RETURN Count
  21. ENDFUNCTION
  22. 1 mark for each of the following:
  23. 1 Function heading and ending including parameter and return type
  24. 2 OPENFILE LogFile for APPEND and subsequent CLOSE
  25. 3 Loop for 2000 iterations
  26. 4 Extract first 6 characters from array element in a loop
  27. 5 Compare first 6 characters with parameter in a loop
  28. 6 If equal:
  29. • write whole array element string to file and
  30. • increment Count and
  31. • clear array element in a loop
  32. 7 Return Count (must have been declared and initialised)

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, 10 marks.
Source
A-Level Computer Science, Oct/Nov 2021 Paper 2 Variant 1, question 5.

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