Data Entry Specialist

Victor Cruzat

Data Entry Specialist
Backend Engineer
Cybersecurity
Python
React
TypeScript
MENU = {
    "espresso": {
        "ingredients": {
            "water": 50,
            "coffee": 18,
        },
        "cost": 1.5,
    },
    "latte": {
        "ingredients": {
            "water": 200,
            "milk": 150,
            "coffee": 24,
        },
        "cost": 2.5,
    },
    "cappuccino": {
        "ingredients": {
            "water": 250,
            "milk": 100,
            "coffee": 24,
        },
        "cost": 3.0,
    }
}
profit = 0
resources = {
    "water": 300,
    "milk": 200,
    "coffee": 100,
}
def is_resource_sufficient(order_ingredients):
    """Returns true when order can be made, False if order is sufficient"""
    for item in order_ingredients:
        if order_ingredients[item] >= resources[item]:
            print(f"Sorry there is not enough {item}.")
            return False
    return True


def process_coins():
    """Returns the total calculated from the coins inserted"""
    print("Please insert coins.")
    total = int(input("how many quarters?: ")) * 0.25
    total += int(input("how many dimes?: ")) * 0.1
    total += int(input("how many nickles?: ")) * 0.05
    total += int(input("how many pennies?: ")) * 0.01
    return total


def is_transaction_successful(money_received, drink_cost):
    """Return true when payment accepted or False when money is insufficient"""
    if money_received >= drink_cost:
        change = round(money_received - drink_cost, 2)
        print(f"Here is ${change} in change.")
        global profit
        profit += drink_cost
        return True
    else:
        print("Sorry that is not enough money. Money refunded.")
        return False

def make_coffee(drink_name, order_ingredients):
    """Deduct the required ingredients from the resources."""
    for item in order_ingredients:
        resources[item] -= order_ingredients[item]
    print(f"Here is your {drink_name} ")


is_on = True

while is_on:
# TODO: 1.Prompt the user to input what they want
    choice = (input("What would you like? (espresso/latte/cappuccino):" ))

# TODO: 2. Turn off the coffee machine by entering the off prompt
    if choice == "off":
        is_on = False
# TODO: 3. Print Report
    elif choice == "report":
        print(f"Water: {resources['water']}")
        print(f"Milk: {resources['milk']}ml")
        print(f"Coffee: {resources['coffee']}g")
        print(f"Money: ${profit}")
# TODO: 4. Check if resources are sufficient
    else:
        drink = MENU[choice]
        if is_resource_sufficient(drink["ingredients"]):
#TODO : Process Coins
            payment = process_coins()

#TODO 6. check if transaction is successful
            if is_transaction_successful(payment, drink["cost"]):
#TODO 7. Call for coffee to be made
                make_coffee(choice, drink["ingredients"])
                
Partner With Victor
View Services

More Projects by Victor