Sunday, June 17, 2012

Rounding Decimal Points (Money)

Just a random code I made when got nothing to do, figured might have to count money stuffs sooner or later.

a = raw_input("First price")
b = raw_input("Second price")
c = raw_input("Third price")

try:
    a = float(a)
    if a < 0:
        print "Please enter positive values"
        exit()

    b = float(b)
    if b < 0:
        print "Please enter positive values"
        exit()

    c = float(c)
    if c < 0:
        print "Please enter positive values"
        exit()

except:
    print "Invalid"
    exit()

def ExtraCost(a,b,c):
    cost = a + b + c
    gst = cost * 0.07
    svc = cost * 0.1
    print "Intial cost is $" + `round(cost, 2)`
    print "GST is $" + `round(gst, 2)`
    print "Service charge is $" + `round(svc, 2)`
    total = cost + gst + svc
    return round(total, 2)

print "Final cost is $" + `ExtraCost(a,b,c)`

Sunday, 17th June 2012

Woke up around 4 today x.x
Last night slept too late, nothing to do today anyway
Slacking~

Think will get this on Tuesday for Muffin




Don't feel like going to school tomorrow cause I got 3 Cs from 5 lessons only =.=
Wonder what do I have to write to get B or better...