![]() |
|
#1
|
|||
|
|||
C++ Candy machine simulation (m0g0l)Candy 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.... |
|||
|
#2
|
|||
|
|||
Re: c++ Candy machine simulation(m0g0l)So far so good... this is what I've made...please bear with me..I'm a newbie when it comes to C++...tsk3x!!
CPP / C++ / C Code:
the next code, or what to do next... I don't know how... please I beg help need help! Thanks in advance. Last edited by admin : 07-Feb-2008 at 16:46.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
Recent GIDBlog
Updates On The All New Toyota VIOS - Part III by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MACRO to detect big / little endian | ahbi82 | C Programming Language | 14 | 26-Aug-2007 10:33 |
| VS 2008 beta2 's fatal error LNK1112: module machine type 'x64' conflicts with target | wincasy | MS Visual C++ / MFC Forum | 0 | 29-Jul-2007 07:37 |
| Xchange machine | an1 | CPP / C++ Forum | 0 | 04-May-2007 09:48 |
| apache server cannot access through another machine | benluo | Apache Web Server Forum | 0 | 13-Jul-2004 19:28 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The