Question 4(c)(iv) 2021 · May-June · Paper 42 · 15 marks
Reveal official mark-scheme answer
The answer for this question is in the official mark scheme: open the mark scheme.
Show text version of question
Question 4
Part (c)
(iv)
Question 4
answer
10 points Write program code for the procedure, readData() to: • read each question, answer and points from the text file • create an object of type TreasureChest for each question • declare an array named arrayTreasure of type TreasureChest • append each object to the array • use exception handling to output an appropriate message if the file is not found. Save your program. Copy and paste the program code into part 3(b) in the evidence document.
Question 10
Part (c)
The main program repeats each question until the user inputs the correct answer. The
number of points awarded depends on the number of attempts before the user gives the correct answer.
(iv)
Write program code for the main program to: • call the procedure readData() • ask the user to enter a question number between 1 and 5 • output the question that matches the question number entered by the user • check if the answer input by the user is correct using the method checkAnswer() • repeat the question until the user inputs the correct answer • count how many times the user attempted the question • use the method getPoints() to return the number of points awarded • output the number of points the user is awarded. Save your program. Copy and paste the program code into part 3(c)(iv) in the evidence document.
Why this question appears here
82% assigned-topic match · Programming › Constructs
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9618_s21_qp_42.pdf
