Answer:
In Python:
prices = []
pounds = []
print("Enter 0 to stop input")
for i in range(10):
pr = float(input("P rice: "+str(i+1)+": "))
pd = float(input("Pound: "+str(i+1)+": "))
if pr != 0 and pd != 0:
prices.append(pr)
pounds.append(pd)
else:
break
amount = 0
for i in range(len(pounds)):
amount+= (pounds[i]*prices[i])
print("Amount: $",amount)
Step-by-step explanation:
These initialize the prices and pounds lists
prices = []
pounds = []
This prompts the user to enter up to 10 items of press 0 to quit
print("Enter 0 to stop input")
This iterates through all inputs
for i in range(10):
This gets the price of each item
pr = float(input("P rice: "+str(i+1)+": "))
This gets the pound of each item
pd = float(input("Pound: "+str(i+1)+": "))
If price and pound are not 0
if pr != 0 and pd != 0:
The inputs are appended to their respective lists
prices.append(pr)
pounds.append(pd)
If otherwise, the loop is exited
else:
break
This initializes total to 0
amount = 0
This iterates through all inputs
for i in range(len(pounds)):
This multiplies each pound and each price and sum them up
amount+= (pounds[i]*prices[i])
The total is then printed
print("Amount: $",amount)