Java Reference
In-Depth Information
Flowchart of a do Loop
In practice, this situation is not very common. You can always replace a do loop
with a while loop, by introducing a boolean control variable.
boolean done = false;
while (!done)
System.out.print("Please enter a positive
number: ");
value = in.nextDouble();
if (value > 0) done = true;
R ANDOM F ACT 6.1: Spaghetti Code
In this chapter we are using flowcharts to illustrate the behavior of the loop
statements. It used to be common to draw flowcharts for every method, on the
theory that flowcharts were easier to read and write than the actual code
(especially in the days of machine-language and assembler programming).
Flowcharts are no longer routinely used for program development and
Flowcharts have one fatal flaw. Although it is possible to express the while and
do loops with flowcharts, it is also possible to draw flowcharts that cannot be
Search WWH ::

Custom Search