Java Reference
In-Depth Information
programmed with loops. Consider the chart in the Spaghetti Code figure. The top
of the flowchart is simply a statement
years = 1;
The lower part is a do loop:
do
{
years++;
double interest = balance * rate / 100;
balance = balance + interest;
}
while (balance < targetBalance);
But how can you join these two parts? According to the flowchart, you are
supposed to jump from the first statement into the middle of the loop, skipping the
first statement.
years = 1;
goto a; //
Not an actual
Java
statement
do
{
years++;
a:
double interest = balance * rate / 100;
balance = balance + interest;
}
while (balance < targetBalance);
235