A customer in a store is purchasing five items. Write a program that asks for the price of each item, and then displays the subtotal of the sale, the amount of sales tax, and the total. Assume the sales tax is 6 percent

Total Purchase

A customer in a store is purchasing five items. Write a program that asks for the price of each item, and then displays the subtotal of the sale, the amount of sales tax, and the total. Assume the sales tax is 6 percent.

Solution

#ask price of each item

item1 = float(input(“Enter the price of item1: “))

item2 = float(input(“Enter the price of item2: “))

item3 = float(input(“Enter the price of item3: “))

item4 = float(input(“Enter the price of item4: “))

item5 = float(input(“Enter the price of item5: “))

#calculate the subtotal of 5 items

subTotal = (item1 + item2 + item3 + item4 + item5)

#calculate the tax

salesTax = subTotal * 0.06

#calculate  toal

total = subTotal + salesTax

#disply subtotal,saletax,total

print(“sub total :”,format(subTotal , ‘,.2f’))

print(“sales tax :”,format(salesTax , ‘,.2f’))

 

print(“total :”,format(total , ‘,.2f’))