473,508 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cash Register

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 SLAES $ ',v
Jul 18 '05 #1
4 6321
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 2004-05-11T18:32:33Z, RQ******@optonline.net (Ryan Q.) writes:
It works, i'm just posting it hoping someone could do better.
Of that I'm sure. :-)
while b != 0:


b never goes to 0.

Your variables have meaningless names.

You misspelled 'SALES'.

I would not give that a high grade.
- --
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAoTBY5sRg+Y0CpvERAtA1AJ43lt8H7JpoZu0snjAM29 9mn1CIiwCeIhd3
uCTxtus9K7uemQ9/4xozk30=
=OJ21
-----END PGP SIGNATURE-----
Jul 18 '05 #2
Ryan Q. wrote:
It works, i'm just posting it hoping someone could do better.

print ''
print ' *** CASH REGISTER ***'
print ' PRESS 0 AND THEN ENTER TO TOTAL'


I notice it's nicely agnostic about what kind
of numbers are used. This will come in very handy
if complex currency is ever introduced...

ITEM $ 3.50
ITEM $ 2.30j
ITEM $ 1+2j
ITEM $ 0
TOTAL $ (4.5+4.3j)
CASH $ 50
CHANGE $ (45.5-4.3j)

TOTAL SLAES $ (4.5+4.3j)

--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg

Jul 18 '05 #3
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." <RQ******@optonline.net> wrote in message
news:d1**************************@posting.google.c om...
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

Jul 18 '05 #4
Greg Ewing <gr**@cosc.canterbury.ac.nz> wrote:
I notice it's nicely agnostic about what kind
of numbers are used. This will come in very handy
if complex currency is ever introduced... ITEM $ 3.50
ITEM $ 2.30j
ITEM $ 1+2j
ITEM $ 0
TOTAL $ (4.5+4.3j)
CASH $ 50
CHANGE $ (45.5-4.3j)


Beautiful demonstration of the principle behind the rule that items
with complex prices may only be sold in conjugate pairs! :-)

--
automation: replacing what works with something that almost works,
but which is faster and cheaper. - attributed to Roger Needham
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6305
by: Scott A. Keen | last post by:
Hi, I'm getting tasked with writing an ASP application deployed throughout the company's intranet where all the workstations will be running Internet Explorer 6.0. It's a retail business, and...
1
1952
by: Philippe C. Martin | last post by:
Hi, I just got the pywin32 "hello world" COM server to install and I did manage to use it from VB 6.0. However, there are some glitches I do not comprehend: 1) at one point I got a python...
1
4188
by: Earl Anderson | last post by:
My brother is in the process of purchasing a neighborhood dry cleaners store. Having seen some of the process applications I've written in MS Access, he asked me if I could develop an application...
2
3788
by: carl | last post by:
need to send a command from a POS Application in Microsoft Access 2000 to open a cash drawer. If anyone can help, please contact me. I will pay $$ for very specific directions if I have to. ...
2
3834
by: wahid_kalo | last post by:
Hi There I Have Finished A Point Of Sale Program On Access, I Still Need To ControlThe Cash Register Drawer By Code. In The Manual It Is Mentionned To Open The Drawer through com1 under qbasic...
1
2627
by: Gen | last post by:
Hello there, I am a leader of a team, developing business application based on the ASP.NET platform. Now we need to add cash register support to the application and it seems to be a bit of a...
0
1118
by: SFI | last post by:
just get register and start making money online within few minitues of registration get register http://www.moreinfo247.com/9179906/CB refer others and get $4 on each free referal
1
1140
by: vbsoft | last post by:
How do i develop a CASH REGISTER PROGRAM IN VB.NET and that user can put it on a CHIP I NEED UR HELP.
2
3326
Fary4u
by: Fary4u | last post by:
Hi i'm trying to develop a software in VB for Cash Register - Till Operator the only problem is send amount using serial port that can display the amount to pay. i've got this machine Epos...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
422
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.