Question 2(a) 2016 · May-June · Paper 23 · 8 marks
Reveal official mark-scheme answer

Official answer for Question 2
Part (a)
Part (a)
Example Pascal
Max[8]
- Procedure heading & ending
- Local variables declared
- With correct data types
- Input SnackType
- Correct case statement
- Initialise Total
- REPEAT loop
- Input CoinValue and keep running total
- Calculate change due
- IF statement with procedure call to OutputChange()
- Output “No change”
Question 23
Show text version of question
Question 2
Part (a)
Question 2
A vending machine dispenses four different types of snack: ‘A’, ‘B’, ‘C’ or ‘D’.
The vending machine accepts the following coins: 100 cents, 50 cents, 20 cents, 10 cents. If the user inserts coins to a greater value than the price of the chosen snack, the machine will give change.
The program controlling the machine is to take as input:
- the type of snack chosen (‘A’, ‘B’, ‘C’ or ‘D’)
- the value of each coin inserted
The program output is:
- the message “No change”, if the money inserted was exactly the price of the snack
or
- a message summarising the number of each coin value needed to give the correct change
Question 2 continues on page 4.
Question 4
Part (a)
Write program code to implement the flowchart opposite as the procedure VendingMachine.
Programming Language ...........................................................................................................
Code .........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[8]
Question 5
PROCEDURE VendingMachine
INPUT SnackType
CASE OF SnackType 'A' Price @20
'B' Price @40
'C' Price @50
'D' Price @80
Initialise Total
INPUT CoinValue
Total @Total + CoinValue
Is Total >= No Price?
Yes This is a ChangeDue @Total - Price procedure call
Yes OutputChange Is ChangeDue (ChangeDue) > 0? No OUTPUT "No Change"
ENDPROCEDURE
Question 6
Why this question appears here
71% assigned-topic match · Programming › Programming basics
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 9691_s16_qp_23.pdf
