HP Forums
(15C) Cash Register - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (15C) Cash Register (/thread-10446.html)



(15C) Cash Register - Michael Zinn - 04-04-2018 10:36 PM

This is an implementation of a cash register. What's special about it is that it is optimized for convenient quick usage.

Setup
1. Put the current amount of cash in register 0
2. Put the price list in the other registers.
3. Run A (Abort) to make sure that the register is in initial state.

Example register price list:
1 Fries $1.00
2 Extra Ketchup $0.20
3 Coke $0.80
4 Ice Cream $2.50

Usage
1. First, input what the customer wants to buy. E.g. if they say "2 Fries and 1 Coke" you enter 1 E E 3 E. Notice that you press the E button as many times as the preceeding item is to be sold.
2. Press D when Done. It will now show how much to charge the customer. Tell it to the customer.
3. Enter how much the customer is giving you and then hit C to calculate Change. E.g. if the customer is handing you $10 you'll enter 10 C. The calculator will now show you how much change to give with a negative sign (if it shows a positive sign it means that the customer didn't give you enough money).
4. If all is well hit B like Bye to commit the transaction or hit A like Abort to cancel everything.

At the end of the day, you should check if you actually have as much money as there is in register 0.

Program
Notice that this uses program fall through so you'll have to enter B right before A or it won't work

Code:

LBL E
STO I
RCL (i)
STO + .8
R \/
RTN

LBL D
RCL .8
RTN

LBL C
-
RTN

LBL B
RCL .8
STO + 0
LBL A
0
STO .8
RTN



RE: (15C) Cash Register - Dieter - 04-05-2018 07:31 AM

(04-04-2018 10:36 PM)michaelzinn Wrote:  This is an implementation of a cash register. What's special about it is that it is optimized for convenient quick usage.
...
Notice that this uses program fall through so you'll have to enter B right before A or it won't work

I do not see any problem here. If you press B there is no need to have it followed by A since this already has been executed.
Or maybe I did not understand you correctly. Did you mean that in the program LBL B has to be followed by LBL A? That's the way it is shown in the listing, and of course the user may not rearrange the program the way he likes to. ;-)

Maybe you should note that the price list is stored in register 1 through .7

The "calculate change" routine at LBL C may cause problems since it expects that the amount to pay (R.8) is still in Y.
I would recommend you replace this routine with...

Code:
LBL C
RCL .8
X<>Y
-
RTN

...so that this problem cannot occur. Personally, I would even remove the X<>Y so that the displayed change is negative, which shows that this it money paid out.

For your convenience you may also add a FIX 2 after LBL A.

BTW, the program is so short that all registers are available, so why not use R.9 instead of R.8? That's room for one more item on the price list. ;-)
You can even do it completely without R.8 or R.9, just replace all references to these with the I-register and change LBL E this way:

Code:
LBL E
X<> I
RCL+(i)
X<> I
RTN

That's even one step shorter.

With all suggestions implemented the program would look like this:

Code:
LBL E
X<> I
RCL+(i)
X<> I
RTN

LBL D
RCL I
RTN

LBL C
RCL- I
CHS    (Edit: added this line to display the change with negative sign)
RTN

LBL B
RCL I
STO+0

LBL A
FIX 2
CLX
STO I
RTN

Dieter


RE: (15C) Cash Register - Michael Zinn - 04-05-2018 03:35 PM

Thanks for the feedback!

I think that the change should already be negative, given that you first enter the amount the customer hands over to you before starting C, which will subtract it.

Using I and x<> is a good idea (The reason why I used .8 and not .9 is that I'll be using .9 for something else somewhere)


RE: (15C) Cash Register - Dieter - 04-05-2018 08:26 PM

(04-05-2018 03:35 PM)michaelzinn Wrote:  I think that the change should already be negative, given that you first enter the amount the customer hands over to you before starting C, which will subtract it.

Yes, you are right – my bad. So instead I should add a CHS in my LBL C version. ;-)

Dieter