The program tries out various interest rates starting at zero percent. For each interest rate, the amount of dollars must be reset back to the amount in the account at the beginning of the first year.
Here is a flowchart that shows the logic of the program.
Observe how one loop is nested inside of another.
Notice how dollars
is initialized to initialAmount
each time the inner loop is started.
Look in the flowchart (or program) at how rate
is adjusted to the new rate at the top of the loop body of the outer loop.
Is rate
adjusted at the correct spots in the program?