190k views
0 votes
In this assignment you will write a program for a Vending Machine that sells Coffee and Tea. Your program will first accept coins from the user until the user enters 0 (5, 10, or 25 only - no other numbers), then print a menu for dispensing Coffee or Tea to the user to choose from and then a submenu for Regular or Decaf coffee or Black or Green Tea. If the amount deposited is sufficient, the machine will dispense the item, else it should loop back and ask for more money, and present the menu again

1 Answer

2 votes

Final answer:

The question involves writing a program for a coffee and tea vending machine. It requires accepting coins, checking if the amount is sufficient, and providing a menu for product selection.

Step-by-step explanation:

The student's assignment entails creating a vending machine program that sells Coffee and Tea. The program will accept coins (only 5, 10, or 25 cents) until a 0 is entered. After the total amount is inputted, the program will display a menu offering choices between Coffee or Tea, and further, between Regular or Decaf coffee and Black or Green tea. The key aspect here is developing the logic to check if the deposited amount is sufficient for the purchase. If not, the program should prompt for additional money and present the menu again to complete the transaction.

The task combines concepts of conditional statements, loops, and user input handling in programming. This vending machine example is akin to following precise measurements, much like using a coffee maker or taking measurements in a medical context. Implementing this program will involve handling monetary values and decision-making structures to ensure proper item dispensation.

User Salah Alshaal
by
8.7k points