Vending Machine Simulation
PROFile Handling & SimulationSimulation
State Tracking
Validation
Simulate a vending machine that sells 3 items: item 1 costs 100, item 2 costs 150 and item 3 costs 200 (in pence).
**Step 1:** Input the item number. If it is not 1, 2 or 3, output `Invalid item` and stop.
**Step 2:** Repeatedly input coins until the total inserted is **at least** the price. Only coins of 10, 20, 50 and 100 are accepted. For any other coin value, output `Invalid coin` and ignore it (it does not count towards the total).
**Step 3:** Once enough money has been inserted, output three lines: `Dispensed`, then the change due (total inserted minus price), then the number of valid coins that were inserted.
For example, the inputs 1, 50, 50 produce `Dispensed`, `0` and `2` (one per line).
Example Input
1
50
50
Example Output
Dispensed
0
2
0% (0 passed / 0 attempted)