Find the error(s) in the following code. This code should append the numbers from 10 down to 1 to outputJTextArea.
```
1 int counter = 10;
2
3 do
4 {
5 outputJTextArea.append( counter + "\n" );
6 }
7 while ( counter > 1 );
8
9 --counter;
```
Line 9 should be placed within the body of the do…while statement between lines 5 and 6. The code above causes an infinite loop—counter is never decremented within the do…while statement, so the loop continuation condition never becomes false. Also, once the decrement statement is moved into the body of the loop, there will be an off-by-one- error. The condition should be either counter >= 1 or counter > 0. The corrected code is dis- played below.
```
1 int counter = 10;
2
3 do
4 {
5 outputJTextArea.append( counter + "\n" );
6 --counter;
7 }
8 while ( counter >= 1 );
```
You might also like to view...
To draw a polygon, you pass to the method:
a) a brush or pen b) an array of points c) a brush or pen, and an array of points d) a grid with a list of points drawn on it
.xlsb files do not support macros
Indicate whether the statement is true or false
A virtualization PC commonly has more than one operating system installed
Indicate whether the statement is true or false
Which hardware device connects the devices on a LAN?
A. Firewall B. Router C. Switch