Find the error(s) below:

Assume that the variable counter is declared and initialized to 1. The loop should execute five times, appending the numbers 1–5 to a JTextArea.
```
1 while ( counter < 5 )
2 {
3 numbersJTextArea.append( String.valueOf( counter ) );
4 counter++;
5 }
```

The loop only iterates four times because the loop-condition uses the incorrect rela- tional operator. The condition should use <=. The correct code is:
```
1 while ( counter <= 5 )
2 {
3 numbersJTextArea.append( String.valueOf( counter ) );
4 counter++;
5 }
```

Computer Science & Information Technology

You might also like to view...

PowerPoint's print settings allow you to print slides, handouts, or notes pages.

a. true b. false

Computer Science & Information Technology

Walking across carpet or vinyl floor has minimal impact on potential ESD

Indicate whether the statement is true or false

Computer Science & Information Technology