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.
- (a)(i)For three of the variables that you have used in Task 1, state the name, type and its use.[3]
- (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]
- (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]
- (c)Explain how you show the totals so far (Task 3). You may include programming statements as part of your explanation.[6]
- (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.
- [3] (a) (i) Many correct answers, they must be meaningful. This is an example only.
- – Choice, integer, choice of charity
- – Cost, real, cost of shopping
- – Donation, real, donation calculated from cost of shopping
- [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
- or
- - 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
- or
- - 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
- [5] (b) Any five from:
- Prompt for input of charity choice // prompt for input of value of shopping
- input charity choice
- check for input of 1, 2, or 3
- input value of shopping
- calculate donation
- add donation to the appropriate total
- output name of charity and amount/total amount donated
- Sample Answer.
- REPEAT
- PRINT 'Please enter choice of charity 1, 2. or 3 '
- INPUT Choice
- UNTIL Choice = 1 or Choice = 2 or Choice = 3
- PRINT 'Please enter value of shopping bill '
- INPUT BillValue
- Donation ← BillValue * 0.01
- Total (Choice) ← Total (Choice) + Donation
- PRINT 'Charity ', CharityName (Choice), ' has received a donation of ', Donation
- [6] (c) Maximum six marks in total for question part
- Description (may include reference to program statements)
- – when charity choice = -1
- – display total donation for each charity ...
- – ... with corresponding charity name...
- – description of method for selecting descending order of totals
- – evidence that the method works
- – calculate grand total from 3 totals / sum of all donations
- – output 'GRAND TOTAL DONATED TO CHARITY' and grand total
- [3] (d) Any three from:
- input number of charities
- store the number of charities as a variable
- change the upper value of the choice input
- change the array bounds for total donations etc.// add new variables to hold extra values
- the need to change the code...
- 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 →