Week 1:
print("1. Skittles 2. M&M's\\3. Starbursts 4. Twizzlers\\5. Twix")
while True:
item = input("Enter the number of your item to be purchased: ")
if item == "1":
print("You chose skittles.")
elif item == "2":
print("You chose M&M's.")
elif item == "3":
print("You chose Starbursts.")
elif item == "4":
print("You chose Twizzlers.")
elif item == "5":
print("You chose Twix.")
Week 2:
print("1. Skittles 2. M&M's\\3. Starbursts 4. Twizzlers\\5. Twix")
total = 0
while True:
item = input("Enter the number of your item to be purchased: ")
if item == "1":
print("You chose skittles.")
total += 2
elif item == "2":
print("You chose M&M's.")
total += 2
elif item == "3":
print("You chose Starbursts.")
total += 1
elif item == "4":
print("You chose Twizzlers.")
total += 3
elif item == "5":
print("You chose Twix.")
total += 4
elif item == "exit":
exit()
elif item == "out":
total += round(total*0.0625,2)
print("Your total is: ${}".format(total))
deposit = int(input("How much money did you input? "))
change_due = round(deposit - total,2)
print("Your change due is ${}".format(change_due))
else:
print("Please choose an option or enter \"exit\" to exit the vending machine.")
week 3:
print("1. Skittles 2. M&M's\\3. Starbursts 4. Twizzlers\\5. Twix")
total = 0
while True:
item = input("Enter the number of your item to be purchased: ")
if item == "1":
print("You chose skittles.")
total += 2
elif item == "2":
print("You chose M&M's.")
total += 2
elif item == "3":
print("You chose Starbursts.")
total += 1
elif item == "4":
print("You chose Twizzlers.")
total += 3
elif item == "5":
print("You chose Twix.")
total += 4
elif item == "exit":
exit()
elif item == "out":
total += round(total * 0.0625, 2)
print("Your total is: ${}".format(total))
deposit = int(input("How much money did you input? "))
while deposit < total:
deposit = int(
input("Please input a dollar amount greater than or equal to the total (whole numbers only): "))
change_due = round(deposit - total, 2)
if change_due == 0:
print("No change due.")
else:
print("You are owed {} dollars and {} cents".format(int(change_due), round(change_due - int(change_due),2)))
else:
print("Please choose an option or enter \"exit\" to exit the vending machine.")
week 4:
def print_menu():
print("1. Skittles 2. M&M's\\3. Starbursts 4. Twizzlers\\5. Twix Enter \"out\" to checkout.")
def calculate_total(new_item):
total = 0
if new_item == "1":
print("You chose skittles.")
total += 2
elif new_item == "2":
print("You chose M&M's.")
total += 2
elif new_item == "3":
print("You chose Starbursts.")
total += 1
elif new_item == "4":
print("You chose Twizzlers.")
total += 3
elif new_item == "5":
print("You chose Twix.")
total += 4
return total
def make_change(change_due):
print(
"Here is your change: {} dollars and {} cents".format(int(change_due), round(int(change_due) - change_due, 2)))
print("Have a great day")
def amount_due(total_price):
sales_tax = 0.0625
final_price = total_price * +(total_price * sales_tax)
print("Subtotal: {}".format(total_price))
print("Final total: {}".format(final_price))
deposit = int(input("Enter how much you deposited: "))
while deposit < final_price:
deposit = int(input("Enter an amount greater than or equal to {}".format(final_price)))
make_change(deposit - final_price)
total = 0
while True:
item = input("Enter the number of your item to be purchased: ")
if item == "1":
print("You chose skittles.")
total += 2
elif item == "2":
print("You chose M&M's.")
total += 2
elif item == "3":
print("You chose Starbursts.")
total += 1
elif item == "4":
print("You chose Twizzlers.")
total += 3
elif item == "5":
print("You chose Twix.")
total += 4
elif item == "exit":
exit()
elif item == "out":
sales_tax = 0.0625
total += round(total * sales_tax, 2)
print("Your total is: ${}".format(total))
deposit = int(input("How much money did you input? "))
while deposit < total:
deposit = int(
input("Please input a dollar amount greater than or equal to the total (whole numbers only): "))
change_due = round(deposit - total, 2)
if change_due == 0:
print("No change due.")
else:
print(
"You are owed {} dollars and {} cents".format(int(change_due), round(change_due - int(change_due), 2)))
else:
print("Please choose an option or enter \"exit\" to exit the vending machine.")
I didn't implement the functions because the problem never stated that we had to. Best of luck.