Question: How do I get my python program to loop back and ask the customer for more money if they do not give me enough money?

How do I get my python program to loop back and ask the customer for more money if they do not give me enough money? My program in python is below:

def main ():

ham = 7.50

fried_chicken=5.25

sweet_potatoes=3.50

cornbread=2.00

drinks=1.50

num_ham = int(input("How many hams do you want?"))

num_fried_chicken=int(input("How many fried chicken wings do you want?"))

num_sweet_potatoes=int(input("How many sweet potatoes do you want?"))

num_cornbread=int(input("How many cornbread do you want?"))

num_drinks=int(input("How many drinks do you want?"))

print("Jayden's Soul Food Truck")

cost_ham = ham*num_ham

cost_fried_chicken=fried_chicken*num_fried_chicken

cost_sweet_potatoes=sweet_potatoes*num_sweet_potatoes

cost_cornbread=cornbread*num_cornbread

cost_drinks=drinks*num_drinks

print(str(num_ham)+"HAM@"+str(ham),"=",cost_ham)

print(str(num_fried_chicken)+"fried_chicken@"+str(fried_chicken),"=",cost_fried_chicken)

print(str(num_sweet_potatoes)+"sweet_potatoes@"+ str(sweet_potatoes),"=",cost_sweet_potatoes)

print(str(num_cornbread)+"cornbread@"+str(cornbread),"=",cost_cornbread)

print(str(num_drinks)+"drinks@"+str(drinks),"=",cost_drinks)

sub_total=cost_ham+cost_fried_chicken+cost_sweet_potatoes+cost_cornbread+cost_drinks

discount_am=.0

discount_rate=0.10

discount_procedure_1(sub_total)

discount_total=.0

def discount_procedure_1(sub_total):

if sub_total > 50:

discount_rate = 0.10

discount_am = sub_total*discount_rate

else:

discount_am=.0

print("Sub Total:"+str(sub_total))

print("All orders over $50 will receive a 10% discount")

discount_total = sub_total-discount_am

sales_tax_a = 0.06

sales_tax = discount_total*sales_tax_a

discount_total = discount_total+sales_tax

print("Discount Amount :"+str(discount_am))

print("Sales Tax:"+str(sales_tax_a+sales_tax))

print("Discount Total:"+str(discount_total))

cash_received=float(input("Enter the cash received:"))

if cash_received >= discount_total:

changeReturn=cash_received - discount_total

print("Change Returned:",(changeReturn))

else:

print("Amount owed:",discount_total)

changeReturn(cash_received,changeReturn)

main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!