# MATCH Mini Project — Vending Machine
# match / case + if — product selection and payment logic

# ─────────────────────────────────────────────
# Vending Machine
# ─────────────────────────────────────────────

# Menu:
# water      — 1.00 EUR
# coffee     — 2.00 EUR
# chips      — 1.50 EUR
# chocolate  — 2.50 EUR

print("Available: water / coffee / chips / chocolate")
product = input("Choose a product: ").lower()
amount = float(input("Insert amount (EUR): "))

match product:
    case "water":
        price = 1.00
    case "coffee":
        price = 2.00
    case "chips":
        price = 1.50
    case "chocolate":
        price = 2.50
    case _:
        print("Product not found.")
        price = None

if price is not None:
    if amount >= price:
        change = amount - price
        print(f"{product.capitalize()} dispensed.")
        print(f"Change: {change:.2f} EUR")
    else:
        print(f"Insufficient funds. {product.capitalize()} costs {price:.2f} EUR.")

# ─────────────────────────────────────────────
# Test it
# ─────────────────────────────────────────────

# Choose a product: coffee
# Insert amount (EUR): 5
# Coffee dispensed.
# Change: 3.00 EUR

# Choose a product: chips
# Insert amount (EUR): 1
# Insufficient funds. Chips costs 1.50 EUR.

# Choose a product: pizza
# Product not found.

# ─────────────────────────────────────────────
# Go further
# ─────────────────────────────────────────────

# Add more products to the menu
# What happens if the user inserts exactly the right amount?
# Add a "sold out" case — case "water": print("Sold out.")
