Computers for Smart People by Robert S. Swiatek - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

You may be questioning the use of

            $$$$,$$9.99

rather than

            $$$,$$9.99

for the edited balance. Remember that we need one character for the $ and then one each for the six digits to the left of the decimal point. That is why we need the six dollar signs and one 9 or seven places in all. If the balance were $100,000 and we used

            $$$,$$9.99

as the mask, the result would be printed as

            $0.00

since we have only provided for six positions, but we need seven. As a result, the leftmost digit would be truncated, which is not what we want. The computer will do exactly what we tell it to do. It can’t correct our omissions, such as this.

The last line of our program

            end-program: end

simply ends the program and closes the file. We saw it in the earlier version of this program. As you will agree, these modifications are a huge improvement over what we had. We’re not done yet.