- **C++**
(*http://www.go4expert.com/forums/cpp/*)

- - **c++ candy machine simulation**
(*http://www.go4expert.com/forums/cpp-candy-machine-simulation-t8707/*)

c++ candy machine simulationCandy Machine Simulation
Write a program to simulate a candy machine.Your machine offers candy for 75 cents, gum for 50 cents, and chips for $1.You should ask the user repeatedly which of the three items she wishes to purchase, or whether she wants to quit.If she chooses to purchase an item, she should be asked to insert the proper amount of money.She should be asked how many dollars, quarters, dimes and nickels she has input.Afterward, a message stating that she purchased a particular item for a particular amount should be printed.Her change, if there is any, should be indicated.If she did not put in enough money, a message should state that no item was dispensed for that reason. You should assume that she starts with 3 dollars.If she tries to spend more than the amount she has left, a message should be printed and the transaction should be not allowed.Note that this message should be printed as soon as it is known that she is trying to spend more than she has left.For example, this occurs if she chooses an item that costs more than the amount she has left, or if she tries to insert more money than the amount she has left even if the item is affordable.You should print the amount left after each transaction. When she chooses to quit, a summary of how many of each item she purchased, the total price for them, the overall total spent,the overall change received, and the amount she has left should be printed. Example Options: a.Candy – 75 cents<!--[if !supportLists]--> b.<!--[endif]-->Gum – 50 cents <!--[if !supportLists]-->c.<!--[endif]-->Chips – 1 dollar <!--[if !supportLists]-->d.<!--[endif]-->Quit Candy Machine: You have $3.00.What would you like to buy? User: a Candy Machine: How many dollars? User: 0 Candy Machine: How many quarters? User: 2 Candy Machine: How many dimes? User: 3 Candy Machine: How many nickels? User: 0 Candy Machine: You purchased candy for 75 cents with 80 cents.Your change is 5 cents. Candy Machine: You have $2.25.What would you like to buy? User: a Candy Machine: How many dollars? User: 1 Candy Machine: How many quarters? User: 0 Candy Machine: How many dimes? User: 0 Candy Machine: How many nickels? User: 0 Candy Machine: You purchased candy for 75 cents with 1 dollar.Your change is 25 cents. Candy Machine: You have $1.50.What would you like to buy? User: c Candy Machine: How many dollars? User: 0 Candy Machine: How many quarters? User: 3 Candy Machine: How many dimes? User: 3 Candy Machine: How many nickels? User: 0 Candy Machine: You purchased chips for 1 dollar with 1 dollar and 5 cents.Your change is 5 cents. Candy Machine: You have $.50.What would you like to buy? User: b Candy Machine: How many dollars? User: 0 Candy Machine: How many quarters? User: 1 Candy Machine: How many dimes? User: 0 Candy Machine: How many nickels? User: 2 Candy Machine: You cannot purchase gum for 50 cents with only 35 cents. Candy Machine: You have $.50. What would you like to buy? User: a Candy Machine: You only have 50 cents left.You do not have enough to purchase candy. Candy Machine: You have $.50.What would you like to buy? User: b Candy Machine: How many dollars? User: 0 Candy Machine: How many quarters? User: 1 Candy Machine: How many dimes? User: 3 Candy Machine: You only have 50 cents left.You cannot spend 55 cents. Candy Machine: You have $.50.What would you like to buy? User: d Thank you. You purchased: 2 bars of candy for $1.50 1 bag of chips for $1.00 The total you spent was $2.85. Your total change was $.35. The total amount you have left is $.50. -------------------------------------------------------------------------- i need help... i'm confused on what to do.... |

Re: c++ candy machine simulationthe problem is that u have just posted the question...
nobody will write the code for u here. .. attempt things from ur side ...let us know where the issue/problem is ... and in that case every1 here will b too eager to help u out ... :) |

All times are GMT +5.5. The time now is 09:54. |