Question
Using C++ create the following code for a vending machine: The vending machine will have 4 inputs and will dispense at amounts of 30, 35,
Using C++ create the following code for a vending machine:
The vending machine will have 4 inputs and will dispense at amounts of 30, 35, 40, 45 and 50 cents.
q for quarters which = 25
d for dimes which = 10
n for nickels which = 5
d for dispense
the code will have a running state of the user input.
the vending machine can also not accept a value lower than the previous amount, so if the user inputs a quarter they can not input a nickel or a dime again.
once the amount reaches 30, 35, 40, 45 or 50 cents the user can put in the state d to dispense the soda.
Welcome to the Candy Machine! Running, state is 0 Input: d Running, state is 10 Input: q Running, state is 35 Input: q Invalid input Running, state is 35 Input: n Invalid input Running, state is 35 Input: s Dispensing Soda Running, state is 0 Input
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started