Question: I am creating a python tkinter program to calculate order total for meal purchase. It will not display the sub total, sales tax, and order
I am creating a python tkinter program to calculate order total for meal purchase. It will not display the sub total, sales tax, and order total. Can you show my how to calculate the pricess correctly?
Parts of code:
def receipt:
subtotal, salestax, ordertotal calculatetotal
# else statement to display a receipt message box if all input is valid
receiptmessage fThank you for your order! ElliMay will see you soon!
f
Name: firstnameentry.getfirstnameentry.get
f
Phone Number: phonenumberentry.get
f
Sandwich: sandwichselected.get
f
Taco: tacoselected.get
f
Taco Toppings: noneselected.getpicoselected.getcheddarcheese.get
fsourcream.getpickledonions.getjackcheese.get
f
Combo: comboselected.get
f
Side: sideselected.get
f
Drink: drinkselected.get
f
Sub Total: $subtotal:f
f
Tax: $salestax:f
f
Total: $ordertotal:f
messagebox.showinfoReceipt receiptmessage
def calculatetotal:
calculatetotal function to calculate total price of order
# declaring variables for meal calculations
subtotal float
salestax float
if sandwichselected.get sandwichoptions:
subtotal sandwichprices
if tacoselected.get tacooptions:
subtotal tacoprices
if comboselected "yes":
subtotal addcombo
elif comboselected no:
subtotal nocombo
if sideselected.get sideoptions and comboselected.get "Yes":
subtotal sideprices
if drinkselected.get drinkoptions and comboselected.get "Yes":
subtotal adddrink
taxtotal subtotal salestax
ordertotal subtotal taxtotal
return subtotal, taxtotal, ordertotal
sandwichoptions No Sandwich", BBQ Pulled Pork", "Slawpy Sliders", BBQ Beef Brisket", "Pork Wrangler", BBQ Pork Sliders", "The Ringer", "Best of Both Worlds","Smoked Chicken", BBQ Beef Brisket Sliders", "Chicken Sliders","Slawpy Pork"
# creating parallel list for sandwich prices
sandwichprices
# declaring variable for sandwichoptions list
sandwichselected StringVar
# setting default value of list
sandwichselected.setsandwichoptions
tacooptions No Tacos","BBQ Brisket Tacos","Pork Tacos","Chicken Tacos"
# creating a parallel list for taco prices
tacoprices
# declaring variable for tacooptions list
tacoselected StringVar
# setting default value of list
tacoselected.settacooptions
toppingoptions None"Pico","Cheddar Cheese","Sour Cream","Pickled Red Onions","Jack Cheese" # toppings are not charged an additional fee they are created with checkbuttons
# combo option created with checkbutton
if comboselected "Yes":
addcombo
else:
nocombo
# if combo is selected is added to taco or sandwich price and there is no charge for side and drink
sideoptions No Side","Cole Slaw","Fries","Tator Tots","Potato Salad","Onion Rings"
sideprices
# declaring variable for sideoptions list
sideselected StringVar
# setting default value of list
sideselected.setsideoptions
drinkoptions No Drink","Water","Pepsi","Diet Pepsi","Sierra Mist","Mountain Dew","Diet Mountain Dew","Root Beer"
# declaring variable for drinkoptions list
drinkselected StringVar
# setting default value of list
drinkselected.setdrinkoptions
# declaring price of adding a drink:
adddrink
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
