diff --git a/Coffee Machine/CoffeeMachine.py b/Coffee Machine/CoffeeMachine.py new file mode 100644 index 00000000..fa9ffd25 --- /dev/null +++ b/Coffee Machine/CoffeeMachine.py @@ -0,0 +1,84 @@ +cash=0 +menu={ + 'latte': { + 'ingredients': { + 'water': 200, + 'milk': 150, + 'coffee': 24 + }, + 'cost':150 + }, + + 'espresso': { + 'ingredients': { + 'water': 50, + 'coffee': 18 + }, + 'cost': 100 + }, + + 'cappuccino': { + 'ingredients': { + 'water': 250, + 'milk': 100, + 'coffee': 24 + }, + 'cost': 200 + } + } +def collect_coins(): + print("Please insert coins ") + five= int(input("How many 5 coins? ")) + ten= int(input("How many 10 coins? ")) + twenty= int(input("How many 20 coins? ")) + sum= (five*5)+(ten*10)+(twenty*20) + return sum + +def check_resources(order_ingredients): + for item in order_ingredients: + if order_ingredients[item] > resources[item]: + print(f"Sorry there is not enough {item}.") + return False + return True + +def payment_process(money,drink_cost): + if money>=drink_cost: + change=money-drink_cost + print(f"Here is your change {change}.") + global cash + cash+=drink_cost + return True + else: + print("Sorry that's not enough money. Money refunded.") + return False + +def make_coffee(drink_name,order_ingredients): + for item in order_ingredients: + resources[item] -= order_ingredients[item] + print(f"Here is your {drink_name} ☕. Enjoy!") + +resources= { + 'water': 300, + 'milk': 500, + 'coffee': 350 +} + +flag=False +while not flag: + choice=input("What would you like? (latte/espresso/cappuccino): ") + if choice=='off': + flag=True + elif choice=='report': + print(f"Water: {resources['water']}ml") + print(f"Milk: {resources['milk']}ml") + print(f"Coffee: {resources['coffee']}g") + print(f"Money: ${cash}") + else: + drink=menu[choice] + if check_resources(drink['ingredients']): + payment=collect_coins() + if payment_process(payment,drink['cost']): + make_coffee(choice,drink['ingredients']) + else: + print("Sorry, we don't have enough resources to make that drink.") + print("Thank you for using the coffee machine!") \ No newline at end of file diff --git a/Coffee Machine/README.md b/Coffee Machine/README.md new file mode 100644 index 00000000..3641f5fa --- /dev/null +++ b/Coffee Machine/README.md @@ -0,0 +1,71 @@ +# ☕ Coffee Machine Project + +This is a simple Python project that simulates a coffee vending machine. +Users can choose from different types of coffee, insert coins to pay, and receive their drinks if enough resources and payment are available. + +## Features + +- Menu options: **Latte**, **Espresso**, **Cappuccino** +- Coin collection and payment processing +- Resource checking (water, milk, coffee) +- Transaction management (gives change if needed) +- Report generation for current resources and earnings +- Machine shutdown option (`off` command) + +## How It Works + +1. The machine asks, **"What would you like? (latte/espresso/cappuccino)"**. +2. If enough ingredients are available: + - It asks how many coins the user is inserting (5, 10, 20 coins). + - It checks if the inserted money is enough. + - If yes, it deducts ingredients, gives change if needed, and serves coffee. + - If not, it refunds the money. +3. Special Commands: + - Type `report` to see the current resources and money. + - Type `off` to turn off the machine. + +## Requirements + +- Python 3 + +(No external libraries are required.) + +## How to Run + +1. Save the code in a Python file, e.g., `CoffeeMachine.py`. +2. Open your terminal or command prompt. +3. Navigate to the folder containing `CoffeeMachine.py`. +4. Run the script: + +```bash +python CoffeeMachine.py +``` + +## Example Usage + +``` +What would you like? (latte/espresso/cappuccino): latte +Please insert coins +How many 5 coins? 4 +How many 10 coins? 5 +How many 20 coins? 2 +Here is your change 30. +Here is your latte ☕. Enjoy! +Thank you for using the coffee machine! +``` + +## Project Structure + +``` +CoffeeMachine.py # Main program file +README.md # Project description and instructions +``` + +## Future Improvements + +- Add more drink options. +- Handle invalid inputs more smoothly. +- Introduce different coin denominations. +- Add an admin login to refill resources. + +---