473,657 Members | 2,270 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 6331
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 2004-05-11T18:32:33Z, RQ******@optonl ine.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)

iD8DBQFAoTBY5sR g+Y0CpvERAtA1AJ 43lt8H7JpoZu0sn jAM299mn1CIiwCe Ihd3
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******@opton line.net> wrote in message
news:d1******** *************** ***@posting.goo gle.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

Jul 18 '05 #4
Greg Ewing <gr**@cosc.cant erbury.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
6317
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 some of the workstations are Point-Of-Sale and will need to have cash drawers and bar-code scanners. The project managers want this as a web-application because of the ease of
1
1963
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 runtime error telling me the "testcomserver" was not found - I got rid of that problem by deleteting the appropriate (I hope) registry and reregistering the server
1
4197
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 to use in his new dry cleaning store since the existing one is of 1988 vintage. I told him that although I thought the 'process' involved in a dry cleaners couldn't be too complex and probably could be developed in Access, I had absolutely no...
2
3798
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. please email me at carl@technology4all.com. Time is of the essence. :-)
2
3844
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 OPEN "COM1:300,N8,1" FOR RANDOM AS #1 PRINT #1,"0000000000"
1
2639
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 problem. In general communication with the cash register consists of two steps: 1 - Creation of a text file, describing the items, quantities and prices; 2 - Invoke cash register's driver (which is an exe file in most cases), passing the text file...
0
1126
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
1155
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
3334
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 Touch Screen Terminal & cash register till Dulwich Software for last 3 day i can't find what should i do any help or any body know any coding which i can use in VB ?
0
8411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2740
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 we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.