1. Engineering
  2. Computer Science
  3. so you cant guess how i should solve this problem...

Question: so you cant guess how i should solve this problem...

Question details

so you can't guess, how I should solve this problem????

In C++, it's all what I have, I think your answer in the second picture( I have to do it in 2 part private and public


Task: You are to design and implement a class to simulate a candy machine. The machine allows user to enter coins, and has three items to choose from. If a user enters enough money for a certain item, they can press a button for that item and receive their item and change. The machine keeps track of how many items it has and how much money is stored in the machine. A CandyMachi ne has three items, denoted A, B, C. Item A costs $0.75, B costs $0.90, and C costs $1.25. (You can think of these as a Snickers, Cookies, and a Soda if you would like.) When installed, the machine starts with 5 of A, 3 of B, and 5 of C. It starts with no money inside. When a user wants to buy an item, they add money, like putting coins in the slot. corresponding function is addMoney (int). When they have added enough money, they press the button for the item they want. The corresponding function woul pressCButton (). When the user pushes the button, three things can happer: d be, for example, 1) The item is out 2) They havent entered enough money 3) Theyve entered enough money and they get their item and change The machine prints a message to the screen (see output and formatting below) for each case. If the item is out, it prints that first, even if they havent entered enough money When an item is successfully purchased, the machine takes in the amount of money for the cost of the item. It returns all other money out the return slot. (If the user adds extra money and wants to buy two things, they have to re-enter the excess change from the first item back into the machine.) Assume the machine can always make change- dont worry about dimes/nickles/quarters. The class also allows the user to check how much each item costs, for example, showCostB). It also has a function for the owner of the machine to check how much money is stored in the machine, getAmountStoredMoney ). There are functions to see how much money has been entered, showMoneyEntered (), and to see how many of each item is left, for example getAsRemaining () A skeleton of the class with its respective functions is posted on the shared drive. It also has two main0 functions. The first is a simple main0 that demonstrates the use of a single machine. The second is a comprehensive test using three machines, which you will use when you turn in your assignment. To help you get started, running the simple main0 function should produce the following output

You have entered 60 cents Wise Choice. Receive item A and your 35 cents change below. Item A costs 75 cents. Machine contains $0.75 You need to add an additional 25 cents. Wise Choice. Receive item A and your 80 cents change below. You need to add an additional 75 cents. You need to add an additional 75 cents. Wise Choice. Receive item B and your 35 cents change below. Machine contains $2.40 There are 3 As left. Wise Choice. Receive item A below. There are 2 As left Wise Choice. Receive item A and your 10 cents change below. Wise Choice. Receive item A and your 15 cents change below. Sorry, that item is out. Please choose another. Wise Choice. Receive item B and your 5 cents change below. For full credit, you must output the exact print statements above, down to the capitalization and punctuation. Note that if the user enters exact change, it does not print and your ” This main function is meant to be representative, and may not catch all of the errors (if present) in your class. So you may wish to do your own testing by expanding/changing the test main0. I am intentionally not giving you the results of the comprehensive main0, as that output is akin to the answer key

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution