Skip to main content
O-LevelComputer ScienceProgramming2210/22 · Oct/Nov 2016 · Q120 Marks

The manager of a supermarket needs a program to record donations to charity. Each customer has the choice of three charities to donate to, and 1% of their shopping bill will be donated to the chosen charity. Write and test a program for the manager. • Your program must include appropriate prompts for the entry of data. • Error messages and other output need to be set out clearly. • All variables, constants and other identifiers must have meaningful names. You will need to complete these three tasks. Each task must be fully tested. TASK 1 – Set up the donation system Set up a routine that allows: • the names of three charities to be input and stored • the charity names to be displayed with a number (1, 2 or 3) beside each name • a choice of 1, 2 or 3 to be entered to choose the charity, all other entries rejected • the value of a customer’s shopping bill to be entered • the donation to be calculated • three totals to be set to zero ready to total each charity donation TASK 2 – Record and total each donation For a customer’s shopping bill: • input a charity choice of 1, 2 or 3 • input the value of a customer’s shopping bill • calculate the donation • add the donation to the appropriate total Output the name of the charity and the amount donated. TASK 3 – Show the totals so far Extend TASK 2 to accept: • donations from more customers • a charity choice of -1 to show the totals so far Display the charities’ names and the totals in descending order of totals. Calculate a grand total of all three totals. Output ‘GRAND TOTAL DONATED TO CHARITY’ and the amount of the grand total.

  1. (a)(i)For three of the variables that you have used in Task 1, state the name, type and its use.[3]
  2. (a)(ii)Name and describe the data structure(s) that you have used to store the donation totals for each charity. Explain why you chose your data structure(s).[3]
  3. (b)Write an algorithm to complete Task 2, using either pseudocode, programming statements or a flowchart. You can assume that Task 1 has been completed.[5]
  4. (c)Explain how you show the totals so far (Task 3). You may include programming statements as part of your explanation.[6]
  5. (d)Explain how you would change your solution for Task 1 to allow the number of charities to be set to two, three or four by the manager.[3]

Mark scheme

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

  1. [3] (a) (i) Many correct answers, they must be meaningful. This is an example only.
  2. – Choice, integer, choice of charity
  3. – Cost, real, cost of shopping
  4. – Donation, real, donation calculated from cost of shopping
  5. [3] (a) (ii) - Array // a set of (similar) variables grouped together// description or array declaration applied to the scenario e.g. DonationTotals[1:3] // allows for more efficient programing e.g. use of indices//each charity total can be identified by an index
  6. or
  7. - List // a set of variables grouped together// description or list declaration applied to the scenario e.g. DonationTotals[] // allows for more efficient programing e.g. use of a loop to update each charity
  8. or
  9. - Variables // storage locations that can be changed// description or declaration applied to the scenario e.g. DonationTotal1, DonationTotal2 and DonationTotal3 // e.g. as there are only 3 charities so there is no need to use an array
  10. [5] (b) Any five from:
  11. Prompt for input of charity choice // prompt for input of value of shopping
  12. input charity choice
  13. check for input of 1, 2, or 3
  14. input value of shopping
  15. calculate donation
  16. add donation to the appropriate total
  17. output name of charity and amount/total amount donated
  18. Sample Answer.
  19. REPEAT
  20. PRINT 'Please enter choice of charity 1, 2. or 3 '
  21. INPUT Choice
  22. UNTIL Choice = 1 or Choice = 2 or Choice = 3
  23. PRINT 'Please enter value of shopping bill '
  24. INPUT BillValue
  25. Donation ← BillValue * 0.01
  26. Total (Choice) ← Total (Choice) + Donation
  27. PRINT 'Charity ', CharityName (Choice), ' has received a donation of ', Donation
  28. [6] (c) Maximum six marks in total for question part
  29. Description (may include reference to program statements)
  30. – when charity choice = -1
  31. – display total donation for each charity ...
  32. – ... with corresponding charity name...
  33. – description of method for selecting descending order of totals
  34. – evidence that the method works
  35. – calculate grand total from 3 totals / sum of all donations
  36. – output 'GRAND TOTAL DONATED TO CHARITY' and grand total
  37. [3] (d) Any three from:
  38. input number of charities
  39. store the number of charities as a variable
  40. change the upper value of the choice input
  41. change the array bounds for total donations etc.// add new variables to hold extra values
  42. the need to change the code...
  43. to allow for differing number of charities

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, O-Level Computer Science (syllabus 2210). Structured question, 20 marks.
Source
O-Level Computer Science, Oct/Nov 2016 Paper 2 Variant 2, 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