Advertisement
Poli_Monoteista

zalozenia

Jan 17th, 2022
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. Coffee Machine Program Requirements
  2. 1. Prompt user by asking “What would you like? (espresso/latte/cappuccino):”
  3. a. Check the user’s input to decide what to do next.
  4. b. The prompt should show every time action has completed, e.g. once the drink is
  5. dispensed. The prompt should show again to serve the next customer.
  6. 2. Turn off the Coffee Machine by entering “off” to the prompt.
  7. a. For maintainers of the coffee machine, they can use “off” as the secret word to turn off
  8. the machine. Your code should end execution when this happens.
  9. 3. Print report.
  10. a. When the user enters “report” to the prompt, a report should be generated that shows
  11. the current resource values. e.g.
  12. Water: 100ml
  13. Milk: 50ml
  14. Coffee: 76g
  15. Money: $2.5
  16. 4. Check resources sufficient?
  17. a. When the user chooses a drink, the program should check if there are enough
  18. resources to make that drink.
  19. b. E.g. if Latte requires 200ml water but there is only 100ml left in the machine. It should
  20. not continue to make the drink but print: “Sorry there is not enough water.”
  21. c. The same should happen if another resource is depleted, e.g. milk or coffee.
  22. 5. Process coins.
  23. a. If there are sufficient resources to make the drink selected, then the program should
  24. prompt the user to insert coins.
  25. b. Remember that quarters = $0.25, dimes = $0.10, nickles = $0.05, pennies = $0.01
  26. c. Calculate the monetary value of the coins inserted. E.g. 1 quarter, 2 dimes, 1 nickel, 2
  27. pennies = 0.25 + 0.1 x 2 + 0.05 + 0.01 x 2 = $0.52
  28. 6. Check transaction successful?
  29. a. Check that the user has inserted enough money to purchase the drink they selected.
  30. E.g Latte cost $2.50, but they only inserted $0.52 then after counting the coins the
  31. program should say “Sorry that's not enough money. Money refunded.”.
  32. b. But if the user has inserted enough money, then the cost of the drink gets added to the
  33. machine as the profit and this will be reflected the next time “report” is triggered. E.g.
  34. Water: 100ml
  35. Milk: 50ml
  36. Coffee: 76g
  37. Money: $2.5
  38. c. If the user has inserted too much money, the machine should offer change.
  39. E.g. “Here is $2.45 dollars in change.” The change should be rounded to 2 decimal
  40. places.
  41. 7. Make Coffee.
  42. a. If the transaction is successful and there are enough resources to make the drink the
  43. user selected, then the ingredients to make the drink should be deducted from the
  44. coffee machine resources.
  45. E.g. report before purchasing latte:
  46. Water: 300ml
  47. Milk: 200ml
  48. Coffee: 100g
  49. Money: $0
  50. Report after purchasing latte:
  51. Water: 100ml
  52. Milk: 50ml
  53. Coffee: 76g
  54. Money: $2.5
  55. b. Once all resources have been deducted, tell the user “Here is your latte. Enjoy!”. If
  56. latte was their choice of drink.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement