Respuesta :
Answer:
Counter initialization: [tex]\verb!int i = 2![/tex].
Conditional statement: [tex]\verb!i <= 20![/tex].
Counter modification: [tex]\verb!i += 2![/tex].
Step-by-step explanation:
In the current Java for-loop in this question:
- The counter initialization statement [tex]\verb!int i = 1![/tex] in this for-loop would initialize the counter variable to integer [tex]1[/tex].
- The conditional statement [tex]\verb!i <= 20![/tex] holds as long as the counter is less than or equal to [tex]20[/tex]. Thus, the largest possible value for the counter would be [tex]20\![/tex].
- The counter modification statement [tex]\verb!i++![/tex] is equivalent to [tex]\verb!i += 1![/tex]. This statement would add [tex]1[/tex] to the value of the counter in each iteration.
The even integers between [tex]1[/tex] and [tex]20[/tex] includes [tex]2,\, 4,\, \dots,\, 20[/tex]. It would be necessary to add [tex]2[/tex] each time to get to the next number.
Since the list of even integers starts at [tex]2[/tex], it would be necessary to initialize the counter variable to [tex]2\![/tex] rather than [tex]1[/tex]. Thus, replace the counter initialization statement [tex]\verb!int i = 1![/tex] with [tex]\verb!int i = 2![/tex].
The maximum integer that this loop should print is still [tex]20[/tex]. Thus, the conditional statement [tex]\verb!i <= 20![/tex] does not need to be changed.
The for-loop should add [tex]2[/tex] to the counter each time to get to the next even integer. Thus, the counter modification statement [tex]\verb!i++![/tex] (or equivalently, [tex]\verb!i += 1![/tex]) should be replaced with [tex]\verb!i += 2![/tex].
Overall, the for-loop should be:
[tex]\begin{aligned}& \verb!for (int i = 2; i <= 20; i += 2) {!\\ &\quad \verb!System.out.print(i + " ");! \\ &\verb!}!\end{aligned}[/tex].