Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Created by Brenton
- #Date 7/30/17
- def main():
- #Declare Variables
- menuCode = "BCFLRV"
- menuName = ["Birthday Cake",
- "Chocolate",
- "French Vanilla",
- "Lemon",
- "Raspberry Cheesecake",
- "Red Velvet"]
- anotherOrder = "Y"
- index = 0
- #User Inputs
- customerName = str()
- cupcakeType = str()
- cupcakeQty = 0
- #Order Variables
- orderQty = [0] * len(menuName)
- orderSubTotal = float()
- orderTax = float()
- orderTotal = float()
- #Daily Variables
- dailyQty = [0] * len(menuName)
- dailyCount = ""
- dailyTotal = ""
- #Declare Constants
- cupcakeCost = 2.00
- taxRate = 0.06
- #Loop for additional customers / orders
- while anotherOrder == "Y":
- customerName = input("Enter the name of the customer ==> ")
- cupcakeType, index = displayMenu(menuCode, menuName)
- #Loop to add cupcakes to the order
- while cupcakeType != "Q":
- #Get the quantity ordered
- cupcakeQty = int(input("How many cupcakes do you want to buy of this type ==> "))
- #Add to quantity accumulator and determine item cost
- orderQty[index] = orderQty[index] + cupcakeQty
- #Print out what was just added to the order
- print()
- print("Item Name:\t", menuName[index])
- print("Item Quantity:\t", cupcakeQty)
- print("Total Cost:\t$ {0:,.2f}".format(cupcakeQty * cupcakeCost))
- print()
- #print out current order summary
- print("Current Order Summary")
- print("*~" * 29)
- displayTotals(menuName, orderQty, cupcakeCost)
- print("*~" * 29)
- print("")
- #Get the next menu choice
- cupcakeType, index = displayMenu(menuCode, menuName)
- #Calculate order subtotal, tax, and total cost
- orderSubTotal = sum(orderQty) * cupcakeCost
- orderTax = orderSubTotal * taxRate
- orderTotal = orderSubTotal + orderTax
- #Print out current order totals
- print("Order Totals")
- print("~" * 50)
- print("\tSubtotal\t==>\t$ {0:6.2f}".format(orderSubTotal))
- print("\tTax\t\t==>\t$ {0:6.2f}".format(orderTax))
- print("\tOrder Total\t==>\t$ {0:6.2f}".format(orderTotal))
- print("~" * 50)
- print()
- #Reset quantities for next order
- for index in range (len(menuName)):
- dailyQty[index] = dailyQty[index] + orderQty[index]
- orderQty[index] = 0
- #Ask the user if they would like to continue
- anotherOrder = input("Do you want to create a new order? Enter Y to continue or Q to quit: ").upper()
- #Determine daily totaalls
- dailyCount = sum(dailyQty)
- dailyTotal = dailyCount * cupcakeCost
- #Print out daily totals
- print()
- print("Daily Totals")
- print("*~" * 29)
- displayTotals(menuName, dailyQty, cupcakeCost)
- print("\t\t\t=====================")
- print("{0:25s}{1:3d}\t $ {2:6.2f}".format("",dailyCount, dailyTotal))
- print("*~" * 29)
- print()
- def displayMenu(menuCode, menuName):
- #Declare local variables
- menuChoice = str()
- index = 0
- typeFound = False
- print("Select from the menu below:")
- for index in range (len(menuName)):
- print("\t" + menuCode[index] + " = " + menuName[index])
- print("\tQ = Quit")
- print()
- menuChoice = input("Enter your selection ==> ")
- menuChoice = menuChoice.upper()
- while (typeFound == False and menuChoice != "Q"):
- if menuChoice in menuCode:
- index = menuCode.find(menuChoice)
- typeFound = True
- else:
- menuChoice = input("Your selection is invalid. Please try again ==> ").upper()
- return menuChoice,index
- def displayTotals(menuName, quantity, cupcakeCost):
- #Declare local variables
- index = 0
- for index in range (len(menuName)):
- print("{0:25s}{1:3d}\t $ {2:6.2f}".format(menuName[index], quantity[index], quantity[index] * cupcakeCost))
- return
- main()
Add Comment
Please, Sign In to add comment