187k views
0 votes
JAVA

Use a for loop to print the even numbers between 1 and 50, including the first even number, and the number 50. Print each number on a new line.

1 Answer

5 votes

public class JavaApplication65 {

public static void main(String[] args) {

for (int i = 1; i <= 50; i++){

if (i % 2 == 0){

System.out.println(i);

}

}

}

}

I hope this helps!

User Second Son
by
5.5k points