Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Coffee Machine Program Requirements 1 . Prompt user by asking What would you like? ( espresso / latte / cappuccino ) : a . Check
Coffee Machine Program Requirements
Prompt user by asking What would you like? espressolattecappuccino:
a Check the users input to decide what to do next.
b The prompt should show every time action has completed, eg once the drink is
dispensed. The prompt should show again to serve the next customer.
Turn off the Coffee Machine by entering off to the prompt.
a For maintainers of the coffee machine, they can use off as the secret word to turn off
the machine. Your code should end execution when this happens.
Print report.
a When the user enters report to the prompt, a report should be generated that shows
the current resource values. eg
Water: ml
Milk: ml
Coffee: g
Money: $
Check resources sufficient?
a When the user chooses a drink, the program should check if there are enough
resources to make that drink.
b Eg if Latte requires ml water but there is only ml left in the machine. It should
not continue to make the drink but print: Sorry there is not enough water.
c The same should happen if another resource is depleted, eg milk or coffee.
Process coins.
a If there are sufficient resources to make the drink selected, then the program should
prompt the user to insert coins.
b Remember that quarters $ dimes $ nickles $ pennies $
c Calculate the monetary value of the coins inserted. Eg quarter, dimes, nickel,
pennies x x $
Check transaction successful?
a Check that the user has inserted enough money to purchase the drink they selected.
Eg Latte cost $ but they only inserted $ then after counting the coins the
program should say Sorry that's not enough money. Money refunded.
b But if the user has inserted enough money, then the cost of the drink gets added to the
machine as the profit and this will be reflected the next time report is triggered. Eg
Water: ml
Milk: ml
Coffee: g
Money: $
c If the user has inserted too much money, the machine should offer change.
EgHere is $ dollars in change. The change should be rounded to decimal
places.
Make Coffee.
a If the transaction is successful and there are enough resources to make the drink the
user selected, then the ingredients to make the drink should be deducted from the
coffee machine resources.
Eg report before purchasing latte:
Water: ml
Milk: ml
Coffee: g
Money: $
Report after purchasing latte:
Water: ml
Milk: ml
Coffee: g
Money: $
b Once all resources have been deducted, tell the user Here is your latte. Enjoy! If
latte was their choice of drink.
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