Sign InCreate Account

Upgrade to Pro

Upgrade Now

Coding Workspace

EditorProjectsPractice QuestionsTimed Mock ExamsFlowcharts

PseudoEditor AI

Pseudocode TutorCode GeneratorCode FixerCode Converter
Back to Problems
PreviousNext

Sign in to run tests against edge cases and save your code automatically.

Problem Description

Hard

Vending Machine Simulation

PROFile Handling & Simulation
Simulation
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

Success Rate:

0% (0 passed / 0 attempted)

Code

Draft auto-saved

Test Results

Click "Test Code" to evaluate your code against the tests.

Product

For SchoolsOverviewFeaturesFAQ
PseudoEditor

© 2026 PseudoEditor. All rights reserved.