Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing


  • 3 years ago

Write a program to simulate a vending machine and calculate change based on the amount paid. Given the cost, the user should first be prompted to add more money until the cost is met/exceeded by the payment. Assume that all change is given in coins only and coins come in the following denominations: R5, R2, R1, 50c, 20c, 10c, 5c

  • This Question is Open
  1. larrymud
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    This is a classic State Machine problem. Use the total deposited as the state. Use transition events like vend, addcoin and cancel. Many State Machine examples can be found online a good example for this problem is here:

  2. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy