Skip to main content
A-LevelComputer ScienceProgramming9618/41 · May/June 2022 · Q129 Marks

The text file HighScore.txt stores the players who have scored the top ten scores in a game, in descending order of score. The file stores the 3-character name of the player, and their integer score, in the order: player, score. For example, the current top player in the text file: FYI is the player name 10000 is the score The program: • reads in the data from HighScore.txt • allows the user to enter a new player name and their score • if appropriate, inserts the new player (name and score) into the top ten • writes the top ten players (name and score) into a new text file NewHighScore.txt

  1. (a)The program stores the players and their scores in an array of 11 elements (10 elements to be read from the file, 1 element to be inserted by the user). Write a program to declare one or more arrays, as global data structures, to store the player names and their scores. Save your program as Question1_J2022. Copy and paste the program code into part 1(a) in the evidence document.[2]
  2. (b)The procedure ReadHighScores() opens the file HighScore.txt and reads the data into the data structure(s) declared in part 1(a). Write program code to declare the procedure ReadHighScores(). Save your program. Copy and paste the program code into part 1(b) in the evidence document.[6]
  3. (c)The procedure OutputHighScores () outputs all the values in the data structure(s) in the format: PlayerName Score For example, the first two data items: FYI 10000 ABC 9092 Write program code to declare the procedure OutputHighScores(). Save your program. Copy and paste the program code into part 1(c) in the evidence document.[3]
  4. (d)(i)The main program should first call ReadHighScores () and then OutputHighScores(). Write the program code for the main program. Save your program. Copy and paste the program code into part 1(d)(i) in the evidence document.[2]
  5. (d)(ii)Test your program. Take a screenshot to show the output from part 1(d)(i). Copy and paste the screenshot into part 1(d)(ii) in the evidence document.[1]
  6. (e)(i)The main program needs to ask the user to input a new player name and a score. If this score is in the top ten then it will create a new top ten list that includes this score. Amend the main program to ask the user to input a 3-character player name and an integer score that must be between 1 and 100000 inclusive. Save your program. Copy and paste the program code into part 1(e)(i) in the evidence document.[3]
  7. (e)(ii)Write program code to declare a procedure that: • takes the player name and score as parameters • creates a new top ten list that includes the parameter if appropriate. Save your program. Copy and paste the program code into part 1(e)(ii) in the evidence document.[5]
  8. (e)(iii)Amend the main program to call the procedure from part 1(e)(ii). Output the contents of the array before inserting the new player name and score, and output the contents of the array after inserting the new player name and score. Save your program. Copy and paste the program code into part 1(e)(iii) in the evidence document.[2]
  9. (e)(iv)Test your program by entering the player name "JKL" and the score "9999". Take a screenshot to show the output. Copy and paste the screenshot into part 1(e)(iv) in the evidence document.[1]
  10. (f)The procedure WriteTopTen() stores the new top ten player names and scores in a text file called NewHighScore.txt Write program code to declare the procedure WriteTopTen(). Save your program. Copy and paste the program code into part 1(f) in the evidence document.[4]

Mark scheme

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

  1. [1] declaration of at least 1 array with appropriate identifier
  2. [1] 11 elements (and appropriate data type(s))
  3. [1] procedure declaration (and end)
  4. [1] Opening the text file (to read)
  5. [1] Looping 10 times // looping until end of file (e.g. 10 pairs of data)
  6. [1] Reading in each pair of lines ...
  7. [1] storing player name and score in data structure(s)
  8. [1] closing the file
  9. [1] Try and catch on file handling
  10. [1] with suitable output
  11. [1] procedure heading and end
  12. [1] looping through all data structure elements
  13. [1] outputting player name, space, score. Each player must start on a new line
  14. [1] (Main program) calls ReadHighScores()
  15. [1] ... then calls OutputHighScores()
  16. [1] 1 mark for screenshot showing the 10 names and scores from the file (and one extra blank space may, or may not be included)
  17. [1] Read in a username and score
  18. [1] Validate username input (3-characters, or just selecting the first 3 characters if there are definitely 3 characters)
  19. [1] Validate score input (integer (cast) between 1 and 100 000 inclusive)
  20. [1] procedure declaration (and close where appropriate) taking 1 string and 1 integer parameter
  21. [1] looping through each array element
  22. [1] finding the position to input the score
  23. [1] storing the array data in the correct position
  24. [1] storing the name and score in the correct position
  25. [1] Calling sorting procedure with correct parameters
  26. [1] Outputting the array before and after procedure call
  27. [1] 1 mark for screenshot. JKL, 9999 entered. After shows JKL in the second position.
  28. [1] procedure header and end (where appropriate) and opening the file NewHighScore.txt to write
  29. [1] Closing the file
  30. [1] Looping through all 10 array values ...
  31. [1] writing the username, then the score
  32. [1] Exception handling and appropriate output

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, 29 marks.
Source
A-Level Computer Science, May/June 2022 Paper 4 Variant 1, question 1.

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