Guest User

Untitled

a guest
Jun 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  1. #Created by Brenton
  2. #Date 7/30/17
  3.  
  4.  
  5. def main():
  6.  
  7. #Declare Variables
  8. menuCode = "BCFLRV"
  9. menuName = ["Birthday Cake",
  10. "Chocolate",
  11. "French Vanilla",
  12. "Lemon",
  13. "Raspberry Cheesecake",
  14. "Red Velvet"]
  15. anotherOrder = "Y"
  16. index = 0
  17.  
  18. #User Inputs
  19. customerName = str()
  20. cupcakeType = str()
  21. cupcakeQty = 0
  22.  
  23. #Order Variables
  24. orderQty = [0] * len(menuName)
  25. orderSubTotal = float()
  26. orderTax = float()
  27. orderTotal = float()
  28.  
  29. #Daily Variables
  30. dailyQty = [0] * len(menuName)
  31. dailyCount = ""
  32. dailyTotal = ""
  33.  
  34. #Declare Constants
  35. cupcakeCost = 2.00
  36. taxRate = 0.06
  37.  
  38. #Loop for additional customers / orders
  39. while anotherOrder == "Y":
  40. customerName = input("Enter the name of the customer ==> ")
  41. cupcakeType, index = displayMenu(menuCode, menuName)
  42.  
  43. #Loop to add cupcakes to the order
  44. while cupcakeType != "Q":
  45. #Get the quantity ordered
  46. cupcakeQty = int(input("How many cupcakes do you want to buy of this type ==> "))
  47.  
  48. #Add to quantity accumulator and determine item cost
  49. orderQty[index] = orderQty[index] + cupcakeQty
  50.  
  51. #Print out what was just added to the order
  52. print()
  53. print("Item Name:\t", menuName[index])
  54. print("Item Quantity:\t", cupcakeQty)
  55. print("Total Cost:\t$ {0:,.2f}".format(cupcakeQty * cupcakeCost))
  56. print()
  57.  
  58. #print out current order summary
  59. print("Current Order Summary")
  60. print("*~" * 29)
  61. displayTotals(menuName, orderQty, cupcakeCost)
  62. print("*~" * 29)
  63. print("")
  64.  
  65. #Get the next menu choice
  66. cupcakeType, index = displayMenu(menuCode, menuName)
  67.  
  68. #Calculate order subtotal, tax, and total cost
  69. orderSubTotal = sum(orderQty) * cupcakeCost
  70. orderTax = orderSubTotal * taxRate
  71. orderTotal = orderSubTotal + orderTax
  72.  
  73. #Print out current order totals
  74. print("Order Totals")
  75. print("~" * 50)
  76. print("\tSubtotal\t==>\t$ {0:6.2f}".format(orderSubTotal))
  77. print("\tTax\t\t==>\t$ {0:6.2f}".format(orderTax))
  78. print("\tOrder Total\t==>\t$ {0:6.2f}".format(orderTotal))
  79. print("~" * 50)
  80. print()
  81.  
  82. #Reset quantities for next order
  83. for index in range (len(menuName)):
  84. dailyQty[index] = dailyQty[index] + orderQty[index]
  85. orderQty[index] = 0
  86.  
  87. #Ask the user if they would like to continue
  88. anotherOrder = input("Do you want to create a new order? Enter Y to continue or Q to quit: ").upper()
  89.  
  90. #Determine daily totaalls
  91. dailyCount = sum(dailyQty)
  92. dailyTotal = dailyCount * cupcakeCost
  93.  
  94. #Print out daily totals
  95. print()
  96. print("Daily Totals")
  97. print("*~" * 29)
  98. displayTotals(menuName, dailyQty, cupcakeCost)
  99. print("\t\t\t=====================")
  100. print("{0:25s}{1:3d}\t $ {2:6.2f}".format("",dailyCount, dailyTotal))
  101. print("*~" * 29)
  102. print()
  103.  
  104. def displayMenu(menuCode, menuName):
  105. #Declare local variables
  106. menuChoice = str()
  107. index = 0
  108. typeFound = False
  109.  
  110. print("Select from the menu below:")
  111. for index in range (len(menuName)):
  112. print("\t" + menuCode[index] + " = " + menuName[index])
  113. print("\tQ = Quit")
  114. print()
  115.  
  116. menuChoice = input("Enter your selection ==> ")
  117. menuChoice = menuChoice.upper()
  118. while (typeFound == False and menuChoice != "Q"):
  119. if menuChoice in menuCode:
  120. index = menuCode.find(menuChoice)
  121. typeFound = True
  122. else:
  123. menuChoice = input("Your selection is invalid. Please try again ==> ").upper()
  124.  
  125. return menuChoice,index
  126.  
  127.  
  128. def displayTotals(menuName, quantity, cupcakeCost):
  129. #Declare local variables
  130. index = 0
  131.  
  132. for index in range (len(menuName)):
  133. print("{0:25s}{1:3d}\t $ {2:6.2f}".format(menuName[index], quantity[index], quantity[index] * cupcakeCost))
  134. return
  135.  
  136. main()
Add Comment
Please, Sign In to add comment