Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import*
- import tkinter.simpledialog
- import tkinter.messagebox
- root = Tk()
- w = Label(root, text="Calculate Tip")
- w.pack()
- food = tkinter.simpledialog.askfloat("Food Price", "Please enter the cost for food.")
- #subtotal is the total of the food and drinks
- subtotal = food
- #15% * the subtotal
- tip = 0.15 * subtotal
- #finish this line so it adds up the subtotal, tip and tax
- total =
- #this line prints out the tip and total value:
- tkinter.messagebox.showinfo("Bill Summary", "Food: $" + str(food) +
- "\nSubtotal: $" + str(subtotal) +
- "\nTip: $" + str(tip) +
- "\nTotal: $" + str(total))
- # Your are to finish writing this program that will calculate the tip
- # for a restaurant bill.
- #
- # 1. Finish the code where you must calculate the total (it will not run
- # unitl you fix it).
- # 2. Make the code calculate the tax for you use 8%. Have it output it
- # and add it to the total.
- # 3. Have the code take in the price of a drink. Then add the drink
- # 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