Java Reference
In-Depth Information
A way to solve this type of problem is shown in Figure A-5, which illustrates the use of an
end-of-file test to terminate the looping process. The value -999999 has been chosen to be the last
account number. This kind of value sometimes is known as the sentinel value because it guards
against continuing past the end-of-file. Also, the numeric item chosen for the last value cannot possi-
bly be confused with a valid item because it is outside the range of the account numbers. Programs
using an end-of-file test, such as the one shown in Figure A-5, are far more flexible and less limited
than programs that do not, such as those illustrated in Figures A-3 and A-4 on pages A.04 and A.05.
Start
Read
First Aging
Account
A
Account
Number =
-999999
Yes
End
No
No
Yes
Age 90
Display
"Send Credit
Memo"
Display
"Turn Over to
Collection Agency"
Read
Next Aging
Account
A
FIGURE A-5
Another flowchart with a loop is shown in Figure A-6, which illustrates the concept of counting.
The flowchart incorporates the end-of-file test.
Simple computer programs do not require complex flowcharts and sometimes do not require
flowcharts at all. As programs become more complex with many different paths of execution, however,
a flowchart not only is useful but usually is a prerequisite for successful analysis and coding. Indeed,
developing the problem solution by arranging and rearranging the flowchart symbols can lead to a
more efficient solution.
Search WWH ::




Custom Search