Advertisement
MrsMcLead

ECS Calculate Tip

Nov 19th, 2013
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. from tkinter import*
  2. import tkinter.simpledialog
  3. import tkinter.messagebox
  4.  
  5. root = Tk()
  6. w = Label(root, text="Calculate Tip")
  7. w.pack()
  8.  
  9. food = tkinter.simpledialog.askfloat("Food Price", "Please enter the cost for food.")
  10.  
  11. #subtotal is the total of the food and drinks
  12. subtotal = food
  13.  
  14. #15% * the subtotal
  15. tip = 0.15 * subtotal
  16.  
  17. #finish this line so it adds up the subtotal, tip and tax
  18. total =
  19.  
  20. #this line prints out the tip and total value:
  21. tkinter.messagebox.showinfo("Bill Summary", "Food: $" + str(food) +
  22.     "\nSubtotal: $" + str(subtotal) +
  23.     "\nTip: $" + str(tip) +
  24.     "\nTotal: $" + str(total))
  25.  
  26.  
  27. # Your are to finish writing this program that will calculate the tip
  28. # for a restaurant bill.
  29. #
  30. # 1. Finish the code where you must calculate the total (it will not run
  31. #    unitl you fix it).
  32. # 2. Make the code calculate the tax for you use 8%.  Have it output it
  33. #    and add it to the total.
  34. # 3. Have the code take in the price of a drink.  Then add the drink
  35. #    to your subtotal.  Make sure to output the price of the drink at the end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement