Simulate a cash register as it totals a user’s purchases. The program should execute for an unspecified number of items for a single user. The program should prompt the user for the quantity and unit cost of each item. The user should indicate the end of purchases by entering a negative quantity. The program should output on one line the quantity, unit cost, item total (the quantity times the unit cost), and the current subtotal to the file
purchases.txt. These values should be separated by a space. The program should output the final total to both the file and the screen.
I have the file I/O down pretty well. What I’m having trouble in class with is creating my loops and making them stop when something is entered.
import os.path
outFile = open("purchases","w")
quantity = raw_input("What is the quantity of the item")
cost = raw_input("How much is each item")
outFile.write()
while quantity <= ???? :
I understand the math but the loop just loses me.
This is a hint:
The loop should loop until the user will enter a negative quantity.
Therefore your loop would look like: