Skip to main content
A-LevelComputer ScienceProgramming9618/42 · Oct/Nov 2024 · Q317 Marks

The text file HighScoreTable.txt stores the top seven player scores for a game. The data in the file is stored in the order: Player ID Game level Score Each item of data is stored on a new line. For example, the first set of data in the file is: Player ID: GHEH Game level: 3 Score: 10

  1. (a)The data about the players and their scores is stored in a 2D array of strings with the identifier HighScores. The first dimension of the array has seven elements: one for each player. The second dimension of the array has three elements: one for the player ID, one for the game level and one for the score. All data is stored in the array as strings. HighScores is declared local to the main program, and all elements are initialised to an empty string, for example "". Write program code to declare and initialise HighScores. Save your program as Question3_N24. Copy and paste the program code into part 3(a) in the evidence document.[2]
  2. (b)The function ReadData() reads the data from HighScoreTable.txt and stores the data in a 2D array. The function returns the 2D array. The function uses exception handling when opening and reading data from the file. Write program code for ReadData(). Save your program. Copy and paste the program code into part 3(b) in the evidence document.[5]
  3. (c)The procedure OutputHighScores() takes a 2D array as a parameter. It outputs each player's ID, level and score in the order they are in the array. The outputs are in the format: GHEH reached level 3 with a score of 10 Write program code for OutputHighScores(). Save your program. Copy and paste the program code into part 3(c) in the evidence document.[2]
  4. (d)The scores in HighScoreTable.txt are not in order. The player scores are first sorted by the game level they reached. For example, all players that reached level 5 are higher in the high score table than players that reached level 4. The players that reached the same level are then sorted in descending order of score. An example sorted high score table is: Position | Player ID | Game level | Score 1 | GFED | 5 | 25 2 | HJKM | 4 | 21 3 | RERR | 4 | 19 4 | TTYU | 4 | 15 5 | WSVG | 3 | 20 6 | PPTR | 3 | 15 7 | SNQT | 2 | 10 The function SortScores() uses a bubble sort to sort the data as described and returns the sorted array. Write program code for SortScores(). Save your program. Copy and paste the program code into part 3(d) in the evidence document.[4]
  5. (e)(i)Amend the main program to implement these steps in the order given: • call ReadData() and store the returned array in HighScores • output "Before" • call OutputHighScores() with HighScores as a parameter • call SortScores() and store the returned array in HighScores • output "After" • call OutputHighScores() with HighScores as a parameter. Save your program. Copy and paste the program code into part 3(e)(i) in the evidence document.[2]
  6. (e)(ii)Test your program Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 3(e)(ii) in the evidence document.[2]

Mark scheme

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

  1. [1] HighScores created as 2D array, (of strings) with (min) 7 × 3 elements (local to main) ...
  2. [1] ... all elements initialised to empty string (" ")
  3. [1] Function header (and end where appropriate) that returns populated array
  4. [1] Opening text file to read and closing the file in an appropriate place
  5. [1] Looping through 7 players/to EOF/21 times ...
  6. [1] ... reading in each group of 3 data items and storing each in separate element in 2D array for each player
  7. [1] Exception handling with all file handling within the try, appropriate catch and an output
  8. [1] Procedure (header and end) taking (min) 1 parameter (2D array), looping through each of the first dimension in array ...
  9. [1] ... outputting all data in correct format
  10. [1] Function header (and end taking array as parameter) returning sorted array.
  11. [1] Comparing the levels and swapping all dimensions when in incorrect order
  12. [1] Comparing scores when levels are the same and swapping all dimensions when in incorrect order
  13. [1] Correct loops and comparisons to put data in correct order
  14. [1] Code statements in order: HighScores = ReadData() HighScores = SortScores(HighScores) // HighScores = SortScores()
  15. [1] Code statements in order: OUTPUT "Before" OutputHighScores (HighScores) unsorted OUTPUT "After" OutputHighScores(HighScores) sorted
  16. [1] Output showing 'Before' and players and scores in correct format before sorting
  17. [1] Output showing 'After' players and scores in correct order and format after sorting

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, 17 marks.
Source
A-Level Computer Science, Oct/Nov 2024 Paper 4 Variant 2, question 3.

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