Fwd: Re: From screen to calculation.

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

 



-----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-----

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
open-cobol-list mailing list
open-cobol-list@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/open-cobol-list




[Index of Archives]     [Gcc Help]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Info]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux