Saturday, January 26, 2019

Python - Buy 8 items and calculate the total

Buy 8 items and out of 8, 6 of them are taxable items. 2 are not. If total crosses $100, give 5% discount. Calculate the total.

print("Welcome to ABC store")
print("Please select the items from list below")
print('')
print("Items        Rate/per item($)")
print("-----        ----------------")
print("Apples          2 ")
print("Bananas         1")
print("Potatoes        3")
print("Medical1        5")
print("Medical2        4")
print("Item1           10")
print("Item2           8")

apple_rate=2
banama_rate=1
potatoes_rate=3
medicine1_rate=5
medicine2_rate=4
item1_rate=10
item2_rate=8

print("")
print("Please enter the quentity of the items you want to buy.")
apple = int(input('Quantity of apples: '))
banana = int(input('Quantity of banana: '))
potatoes = int(input('Quantity of potatoes: '))
medicine1 = int(input('Quantity of Medicine1: '))
medicine2 = int(input('Quantity of Medicine2: '))
item1 = int(input('Quantity of item1: '))
item2 = int(input('Quantity of item2: '))
total_items=apple+banana+potatoes+medicine1+medicine2+item1+item2

print("")
apple_total=apple_rate*apple
banana_total=banama_rate*banana
potatoes_total=potatoes_rate*potatoes
medicine1_total=medicine1_rate*medicine1
medicine2_total=medicine2_rate*medicine2
item1_total=item1_rate*item1
item2_total=item2_rate*item2

print("")
print("Apple Bill is $", apple_total)
print("Banana Bill is $", banana_total)
print("Potato Bill is $", potatoes_total)
print("Medicine1 Bill is $", medicine1_total)
print("Medicine2 Bill is $", medicine2_total)
print("Item1 Bill is $", item1_total)
print("Item2 Bill is $", item2_total)
print("")

taxed_item_total=apple_total+banana_total+potatoes_total+item1_total+item2_total
print("Taxable item total is $",taxed_item_total)
total_tax_bill=float(taxed_item_total*.05)
print("total tax is $",total_tax_bill)
print("")

total_taxable_item=taxed_item_total+total_tax_bill
nontax_total=medicine1_total+medicine2_total
print("Taxable total Bill is $", total_taxable_item)
print("Non-taxable item Bill is $",nontax_total)
total_all=total_taxable_item+nontax_total
print("The total of all item is $", total_all)

if total_all >=100:
    discount=total_all*.05
    grandtotal=total_all-discount
    print("Your total Bill is $", grandtotal)
    print("You saved $",discount," today")
else:
    print("Total Bill is $",total_all)

print("")
print("You have purchased total of",total_items,"items")
print("Thank you for shopping ABC store")



=================== Resumt ====================

Welcome to ABC store
Please select the items from list below

Items        Rate/per item($)
-----        ----------------
Apples          2 
Bananas         1
Potatoes        3
Medical1        5
Medical2        4
Item1           10
Item2           8

Please enter the quentity of the items you want to buy.
Quantity of apples: 2
Quantity of banana: 6
Quantity of potatoes: 7
Quantity of Medicine1: 3
Quantity of Medicine2: 8
Quantity of item1: 9
Quantity of item2: 2


Apple Bill is $ 4
Banana Bill is $ 6
Potato Bill is $ 21
Medicine1 Bill is $ 15
Medicine2 Bill is $ 32
Item1 Bill is $ 90
Item2 Bill is $ 16

Taxable item total is $ 137
total tax is $ 6.8500000000000005

Taxable total Bill is $ 143.85
Non-taxable item Bill is $ 47
The total of all item is $ 190.85
Your total Bill is $ 181.3075
You saved $ 9.5425  today

You have purchased total of 37 items
Thank you for shopping ABC store

No comments:

Post a Comment