Cash Register
Larry Bates
lbates at swamisoft.com
Tue May 11 14:52:21 EDT 2004
Let's see:
1) If user inputs text, program crashes (not good)
Probably should use raw_input and put float() inside
a try block.
2) I can't figure out how program ever stops (e.g. b
is set to 1 and never reset to exit the while b!=0
loop).
3) Sales is mispelled in the last print statement
4) Use inplace incrementing (e.g. v+=s, s+=a)
instead of s=s+a, v=v+s
5) What is t variable used for?
Good Luck.
"Ryan Q." <RQuinn15 at optonline.net> wrote in message
news:d1bd056c.0405111032.3b2c411f at posting.google.com...
> It works, i'm just posting it hoping someone could do better.
>
> print ''
> print ' *** CASH REGISTER ***'
> print ' PRESS 0 AND THEN ENTER TO TOTAL'
> b = 1
> t = 0
> v = 0
> while b != 0:
> a = 1
> s = 0
> print ''
> while a != 0:
> a = input(' ITEM $ ')
> s = s + a
> print ' TOTAL $',s
> v = v + s
> cash = input(' CASH $ ')
> change = cash - s
> print ' CHANGE $',change
> print ' '
> print ' TOTAL SALES $ ',v
More information about the Python-list
mailing list