ccount=0 tcount=0 cokecount=0 while True: print("1.Coffee = $4.00") print("2.Tea = $3.00") print("3.Coca-Cola = $2.00") print("4.Complete order") choice= int(input("Make a selection:")) if choice ==1: quantity=int(input("Enter your quantity:")) ccount+= quantity drink="Coffee" elif choice ==2: quantity=int(input("Enter your quantity:")) tcount+= quantity drink="Tea" elif choice ==3: quantity=int(input("Enter your quantity:")) cokecount+= quantity drink="Coca-Cola" elif choice==4: mem=input('Do u have membership?( Enter Y for yes, N for no):') mem=mem.capitalize() amount=( ccount*4)+(tcount*3)+(cokecount*2) if amount>=10 and mem=='Y': purchaseDisc=amount*0.05 memDisc=(amount-purchaseDisc)*0.15 befTotal=(amount-purchaseDisc-memDisc) gst=befTotal*0.07 total=befTotal+gst elif amount<10 and mem=='Y': purchaseDisc=0 memDisc=amount*0.15 befTotal=amount-memDisc gst=befTotal*0.07 total=befTotal+gst elif amount>=10 and mem=='N': purchaseDisc=amount*0.05 memDisc=0 befTotal=amount-purchaseDisc gst=befTotal*0.07 total=befTotal+gst else: purchaseDisc=0 memDisc=0 befTotal=amount gst=befTotal*0.07 total=befTotal+gst print() print('Receipt') print('==============================') print(f'{"Drink":5s}: {drink:>1s}') print(f'{"Quantity":8s}:{quantity:>13}') print(f'{"Member":6s}:{mem:>15}') print(f'{"Amount":6s}:{"$":>15}{amount:>5.2f}') print(f'{"Purchase Disc.":14s}{"$":>8}{purchaseDisc:>5.2f}') print(f'{"Member Disc.":12s}{"$":>10}{memDisc:>5.2f}') print(f'{"Total (bef. GST)":16s}{"$":>6}{befTotal:>5.2f}') print(f'{"GST":3s}{"$":>19}{gst:>5.2f}') print(f'{"Total (incl. GST)":17s}{"$":>5}{total:>5.2f}') exit()i try to redo my previous codes to this is it more simplier?? However i still cannot print out the 1st input when i enter the 2nd input in this while true loop as they have the same variable name.
How to print out multiple drinks instead of just one based on the input?
Messages In This Thread |
How to print out multiple drinks instead of just one based on the input? - by jayfre - Jun-30-2020, 05:35 PM
RE: How to print out multiple drinks instead of just one based on the input? - by Larz60+ - Jun-30-2020, 06:51 PM
RE: How to print out multiple drinks instead of just one based on the input? - by jayfre - Jun-30-2020, 06:55 PM
RE: How to print out multiple drinks instead of just one based on the input? - by menator01 - Jul-01-2020, 04:15 AM
RE: How to print out multiple drinks instead of just one based on the input? - by menator01 - Jul-01-2020, 06:53 PM
|
Users browsing this thread: 1 Guest(s)