Vending machine problem

Need help on how to start this. Could someone please help me!!!!



1. Create a program that simulates a vending machine. Start with a fixed price for the one item the machine can sell: for example $4.05. Then create a loop that would repeatedly ask for coins to be inserted until the final price is reached or exceeded. Your program should accept coin denominations of one dollar, quarter, dime, and nickel only. In the end, after the cost was accumulated or exceeded, the program should display a message of purchase completion along with any change that might be returned. Your program must use function that are single tasked and well defined.
Hint: you can use a function to display a menu with option for coins to be used. Afterwards, the menu option can be passed to another function that would return the corresponding coin value. This coin value is the one to be accumulated in main inside of a loop that would finished on total amount inserted greater or equal to the price. Working with coins from a menu eliminates the possibility for the user to insert bad coin values.

Sample run (as a suggestion)

Welcome to My Vending machine.
Select a coin to insert from below (1-4)
1. for dollar
2. for quarter
3 for dime
4 for nickel
Your choice (1-4): 7
Invalid choice. Please select again.
Your choice (1-4): 1

Inserted so far: $1.00 out of $4.05

Select a coin to insert from below (1-4)
1. for dollar
2. for quarter
3 for dime
4 for nickel
Your choice (1-4): 2

Inserted so far: $1.25 out of $4.05

....

Inserted so far: $4.35 out of $4.05

Purchase completed!

Your change: $0.30


Start on accepting Input, I imagine you know how to do that, then make a switch for teh input for each coin type.
Topic archived. No new replies allowed.