Jul-22-2020, 04:36 AM
I am doing this question for homework which says: Write a Grocery program that acts as a cash register. The program will prompt how many items they are buying. Then they will input the price of each item (these should be decimal numbers). The program will display SUBTOTAL, TAX (13%), and the TOTAL (with tax)(This is using the While Loop). Make sure you include $ signs and round to two decimal places.I have written the following code below, but the software keeps looping forever. Can someone help me figure why it keep looping
numItems = int(input("How many items are you buying?:")) #Initializes the amount of items and the price subPrice = 0 x = 0 #use conditional loop to loop until the price amount mathces with the number of items while x in range (0,numItems): price = int(input("Enter in a price: $")) #program asks for the price: numItems = numItems + 1 # Counts how many items entered subPrice = subPrice + price # Calculates the sum #Calculates the tax and total price tax = subPrice * 0.13 tax2 = round (tax,2) Total = subPrice - tax total2 = round(total,2) # prints out the Subtotal, tax and Total print ("Subtotal: $", subPrice) print ("Tax", tax2) print ("Total", total2)