Advertisement
The_KGB

[Python]Challenge 5 -- Burgers!

Jul 8th, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.63 KB | None | 0 0
  1. # Global Constants!
  2. BURGER_PRICE = float(0.99)
  3. FRY_PRICE = float(0.79)
  4. SODA_PRICE = float(1.09)
  5. TAX_RATE = float(0.06)
  6.  
  7. # The main function.
  8. def main():
  9.     done = str("no")
  10.     orderInput = int(0)
  11.     numberBurgers = int(0)
  12.     numberFries = int(0)
  13.     numberSodas = int(0)
  14.     while done != "yes" and done != "y" and done != "Y" and done != "Yes" and done != "YES":
  15.         print("For Yum Yum Burger, please enter 1.")
  16.         print("For Grease Yum Fries, please enter 2.")
  17.         print("For Soda Yum, please enter 3.")
  18.         orderInput = input("Please enter your selection: ")
  19.         if orderInput == 1:
  20.             numberBurgers = int(getNumber(orderInput))
  21.             done = raw_input("Will that complete your order? (Y/N) ")
  22.         elif orderInput == 2:
  23.             numberFries = int(getNumber(orderInput))
  24.             done = raw_input("Will that complete your order? (Y/N) ")
  25.         elif orderInput == 3:
  26.             numberSodas = int(getNumber(orderInput))
  27.             done = raw_input("Will that complete your order? (Y/N) ")
  28.         else:
  29.             print("Error! You didn\'t put in 1, 2, or 3 as your selection! Please try again!")
  30.             done = raw_input("Will that complete your order? (Y/N) ")
  31.     totalBurgers = float(numberBurgers * BURGER_PRICE)
  32.     totalFries = float(numberFries * FRY_PRICE)
  33.     totalSodas = float(numberSodas * SODA_PRICE)
  34.     subTotal = float(totalBurgers + totalFries + totalSodas)
  35.     taxTotal = float(TAX_RATE * subTotal)
  36.     completeTotal = float(taxTotal + subTotal)
  37.     dispReceipt(numberBurgers, totalBurgers, numberFries, totalFries, numberSodas, totalSodas, subTotal, taxTotal, completeTotal)
  38.  
  39. # Function to get the number of each item ordered.
  40. def getNumber(orderInput):
  41.     returnNumber = int(0)
  42.     if orderInput == 1:
  43.         returnNumber = int(input("How many Yum Yum Burgers would you like? "))
  44.     if orderInput == 2:
  45.         returnNumber = int(input("How many orders of Grease Yum Fries would you like? "))
  46.     if orderInput == 3:
  47.         returnNumber = int(input("How many cups of Soda Yum would you like? "))
  48.     return returnNumber
  49.  
  50. # Output!
  51. def dispReceipt(numberBurgers, totalBurgers, numberFries, totalFries, numberSodas, totalSodas, subTotal, taxTotal, completeTotal):
  52.     print("Yum Yum Burgers: ", numberBurgers, " @ $", BURGER_PRICE, ": $", totalBurgers)
  53.     print("Grease Yum Fries:", numberFries, " @ $", FRY_PRICE, ": $", totalFries)
  54.     print("Soda Yum:", numberSodas, " @ $", SODA_PRICE, ": $", totalSodas)
  55.     print("Sub-Total:$", subTotal)
  56.     print("Tax@ ", TAX_RATE, "%: $", taxTotal)
  57.     print("Total:$", completeTotal)
  58.  
  59. # Start
  60. main()
  61.  
  62. # End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement