Past-paper question · 2021 May-June · Paper 43 · Q4(c)(iv)

Question 4(c)(iv) 2021 · May-June · Paper 43 · 15 marks

Original past-paper question for 4(C)(IV)
Original past-paper question for 4(C)(IV)
Original past-paper question for 4(C)(IV)
Reveal official mark-scheme answer

The answer for this question is in the official mark scheme: open the mark scheme.

Mark scheme 9618_s21_ms_43.pdf →

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.

[8]

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.

[7]
Topic relevance

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_43.pdf

Keep practising this topic