Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

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

OpenStudy (anonymous):

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: http://www.gamedev.net/blog/802/entry-2217738-system-design----finite-state-machines/

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!