gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] Fwd: Re: From screen to calculation.


From: J Martin Rushton
Subject: [open-cobol-list] Fwd: Re: From screen to calculation.
Date: Fri, 06 Feb 2015 20:16:01 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Always work in cents (or pennies for us on this side of the pond).  I
leave it as an exercise for the reader to convert the answer back!

Consider the following:
- ----%<------
       IDENTIFICATION DIVISION.

       PROGRAM-ID.

       Dollars.

       DATA DIVISION.

       WORKING-STORAGE SECTION.
       77 cash PIC 9999.99.
       77 cents PIC 999999.

       PROCEDURE DIVISION.

       00-Main SECTION.

       000-Init.

       ACCEPT cash FROM SYSIN.
       DISPLAY cash.
       MULTIPLY 100 BY FUNCTION NUMVAL(cash) GIVING cents.
       DISPLAY cents.

       GOBACK
       .
- -----%<------
bash-4.2$ ./Dollars
12.369
0012.36
001236


On 06/02/15 14:41, John Culleton wrote:
> Many programs require data entry in the form of dollars and cents, 
> which data is later used in calculations. The form in which
> dollars and cents is used in calculations is something like
> -9999v99. But the form in which most people will key it is 9999.99
> which cannot be used in calculations. There are many possible
> solutions. One can ask the user to key in 999999 and then
> immediately multiply by .01; the two fields (dollars and cents) can
> actually be two fields next to each other, or some other solution I
> haven't thought of and so on.
> 
> What is your preferred method?
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBAgAGBQJU1SEBAAoJEAF3yXsqtyBlS/YQAJitDfCa0je5b3Y1er/SqDFz
vwQT1h8bAac6cwwprw4VjorksDayUImmYt9sohMARJfZ4VDoOqF6tuoN1xfm4DFI
/ujPSlTCrEflvmIogCIjpiUWvyeYier0k+jCgJojOqSC6J7z7Kh85sQw94CdEe8G
JuMyda2BP0JK0nXy4jT4JgQ6rIsmlgwJy63PtvotGP6o3tl8Cw1+l8PDhdi+g78A
DYwq0eOB2bfbw/aSNEeZ4jBeEI2YYaKahAnjTJlmr9S62ILh8viitMv99Pz8LmOd
zh521OHz6BOVwNMqqHy0DcEw1+//qxPk7aqLGwND1XR7nVGcKCiBfWDgy7FWWeLF
ery2Yk9fstBC2k/CjJKOO/x4PGQDATyMqpH4SCajeHQBGc6UP7Iz6bSiy5qJgGYD
YrltA99DMGPxOR33Kh+pmlkKnKjDknXtOPbt64qwRLnEp+rInQT9E7Iu2ottsPoV
Hcl6ZAPgcYig0dDj4gCw8+Cjm8/T9EuGC9abRLnAQwfuvPPzbMyDwo60i3kGqhSn
v8fcn7n/TDbmCJ0ZnxkqcyA2bPt6BklOq3ZECDtn15rYK8CLakN6cTvqMZO5lAdC
m0DWrZP7DGCRKC1ttLmU4NJD468zX2HyM/EFN+FqesKnlQzUXU46Qkp4ZeZy+A9c
dfrrZLRBtOFIBGTeetzB
=VaKX
-----END PGP SIGNATURE-----


reply via email to

[Prev in Thread] Current Thread [Next in Thread]