I've been trying to make a cash register program and right now this is my draft. For the program, the prices need to add up to a total which than will be calculated with HST and discount amounts. The discount needs to be the lowest number price entered from all the prices, however lowest number won't work and instead will be saved as the highest number.

-num is total price
-price is self explanatory
-lowest is used to store the lowest number
-HST is the tax
-items is the total amount of items

num=0
price=0
lowest=0
HST=0.13
items=0

print "Enter 0 to print receipt.\n-----------------------"

while price>0:

price=raw_input("Enter your price here: $")
price=float(price)
num=num+price#num is the subtotal
print "tag2"

while price<0:
print "Invalid number"
price=raw_input("Enter your price here $")
price=float(price)
num=price+num
print "tag 3"

if (price>0):
if (lowest<=price):
lowest=price
print "tag6"

items=items+1 #total amount of items


print "Subtotal: " ,num
print "Discount: " ,lowest
print "After discount: " ,num-lowest
print "HST: " ,(num-lowest)*HST
print "Total: " ,(num-lowest)+((num-lowest)*HST)
print "-----------------------"
print "tag4"

If user enters negative numbers you discount them from total, is this correct? Use better names whuch are all self explanatory.

That is correct, you are comparing for highest price.

## copied with code tags for other readers
num=0
price=0
lowest=0
HST=0.13
items=0

print "Enter 0 to print receipt.\n-----------------------"

while price>0:

    price=raw_input("Enter your price here: $")
    price=float(price)
    num=num+price#num is the subtotal
    print "tag2"

    while price<0:
        print "Invalid number"
        price=raw_input("Enter your price here $")
        price=float(price)
        num=price+num
        print "tag 3"
        
    ##if (price>0):
    ## if (price>0) is redundant as you check for greater than zero with the while()
    ## while price<0:     should be <= 0
    ##     print "Invalid number"
    if (lowest < price): 
            print "new lowest-->from", lowest, "to", price
            lowest=price

    items=items+1 #total amount of items




print "Subtotal: " ,num
print "Discount: " ,lowest
print "After discount: " ,num-lowest
print "HST: " ,(num-lowest)*HST
print "Total: " ,(num-lowest)+((num-lowest)*HST)
print "-----------------------"
print "tag4"

btw woooeee it still saves the highest number instead of the lowest for discount could you plz fix it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.