146,235 views
15 votes
15 votes
PLEASE HELP!

Make a code that should prompt the user for the prices and quantities of three items. The code should calculate the subtotal of the items. After the subtotal is calculated for your list your code should automatically calculate the sales tax using a tax rate of 5%.
Print out the line items with the quantity and total, and then print out the subtotal, tax amount, and total.

User Miselking
by
2.6k points

1 Answer

29 votes
29 votes

Answer:

subtotal = 0total = 0tax_rate = 6.5for i in range(1,4): price = float(input("Enter the price for item " + str(i) + ": ")) quantity = int(input("Enter the quantity for item " + str(i) + ": ")) subtotal += (price * quantity)tax = subtotal * tax_rate/100total = tax + subtotalprint("Subtotal: " + str(subtotal) + ", Tax: " + str(tax) + ", Total: " + str(total))

Step-by-step explanation:

- Initialize the variables- Create for loop that iterates 3 times- Ask the user for the price and quantity of each item- Calculate the subtotal with given inputs- When the loop is done, calculate the tax and total- Print the subtotal, tax, and total

User LanderV
by
2.9k points