Coffee Machine Write a program that offers to buy one cup of coffee or to fill the supplies or to take its money out. Note that the program is supposed to do one of the mentioned actions at a time. It should also calculate how many ingredients and money have left. Display the number of supplies before and after purchase.
First, your program reads one option from the standard input, which can be "buy", "fill", "take". If a user wants to buy some coffee, the input is "buy". If a special worker thinks that it is time to fill out all the supplies for the coffee machine, the input line will be "fill". If another special worker decides that it is time to take out the money from the coffee machine, you'll get the input "take". If the user writes "buy" then they must choose one of three types of coffee that the coffee machine can make: espresso, latte, or cappuccino. For one espresso, the coffee machine needs 250 ml of water and 16 g of coffee beans. It costs $4. For a latte, the coffee machine needs 350 ml of water, 75 ml of milk, and 20 g of coffee beans. It costs $7. And for a cappuccino, the coffee machine needs 200 ml of water, 100 ml of milk, and 12 g of coffee. It costs $6. If the user writes "fill", the program should ask them how much water, milk, coffee and how many disposable cups they want to add into the coffee machine. If the user writes "take" the program should give all the money that it earned from selling coffee. If the user types "buy" to buy a cup of coffee and then changes his mind, they should be able to type "back" to return into the main cycle. Program should work endlessly to make coffee for all interested people until the shutdown signal is given. Introduce two options: "remaining" and "exit". At the moment, the coffee machine has $550, 400 ml of water, 540 ml of milk, 120 g of coffee beans, and 9 disposable cups.
Do not forget that you can be out of resources for making coffee. If the coffee machine doesn't have enough resources to make coffee, the program should output a message that says it can't make a cup of coffee.
Write action (buy, fill, take, remaining, exit):
remaining
The coffee machine has: 400 of water 540 of milk 120 of coffee beans 9 of disposable cups $550 of money
Write action (buy, fill, take, remaining, exit):
buy
What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:
2 I have enough resources, making you a coffee!
Write action (buy, fill, take, remaining, exit):
remaining
The coffee machine has: 50 of water 465 of milk 100 of coffee beans 8 of disposable cups $557 of money
Write action (buy, fill, take, remaining, exit):
buy
What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:
2 Sorry, not enough water!
Write action (buy, fill, take, remaining, exit):
fill
Write how many ml of water do you want to add:
1000 Write how many ml of milk do you want to add: 0 Write how many grams of coffee beans do you want to add: 0 Write how many disposable cups of coffee do you want to add: 0
Write action (buy, fill, take, remaining, exit):
remaining
The coffee machine has: 1050 of water 465 of milk 100 of coffee beans 8 of disposable cups $557 of money
Write action (buy, fill, take, remaining, exit):
buy
What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:
2 I have enough resources, making you a coffee!
Write action (buy, fill, take, remaining, exit):
remaining
The coffee machine has: 700 of water 390 of milk 80 of coffee beans 7 of disposable cups $564 of money
Write action (buy, fill, take, remaining, exit):
take
I gave you $564
Write action (buy, fill, take, remaining, exit):
remaining
The coffee machine has: 700 of water 390 of milk 80 of coffee beans 7 of disposable cups 0 of money
Write action (buy, fill, take, remaining, exit):
exit