Java Reference
In-Depth Information
A flowchart shows a process that is carried out. Flowcharts are flexible; they can show any logical
process no matter how complex it may be, and they can show it in whatever detail is needed.
The two flowcharts illustrated in Figure A-3 represent the same program, which accepts and then
displays a record. The program then loops back to the accepting operation and repeats the sequence,
accepting and displaying any number of records. A connector symbol, represented by a circle with a
letter or number in it (in this case, A), may replace returning arrows and lines, as it also indicates the
continuation of the looping process.
Start
Start
A
Accept
a Salesperson
Record
Accept
a Salesperson
Record
Display
a Salesperson
Record
Display
a Salesperson
Record
A
Endless Loops
FIGURE A-3
Although the flowcharts in Figure A-3 illustrate two ways a loop can be represented, the particular
loop that is shown is an endless loop , also called an infinite loop . This type of loop should be avoided
when constructing programs. In order to make a program finite, you must define it so that it will
terminate when specified conditions are satisfied.
Figure A-4 illustrates the use of a counter that terminates the looping process. Note that the
counter is first set to 0 in the initialization step. After an account is read and a message is displayed on
the screen, the counter is incremented by 1 and tested to find whether it now is equal to 15. If the value
of the counter is not 15, the looping process continues. If the value of the counter is 15, the looping
process terminates.
 
Search WWH ::




Custom Search