Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

First, launch NetBeans and close any previous projects that may be open (at the

ID: 3876310 • Letter: F

Question

First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).

Then create a new Java application called "EvenThough" (without the quotation marks) that uses a while loop to check the integers 1 through 20 and prints only those integers that are even.

Use division to determine an even integer (i.e., when divided by 2 the result yields no remainder).

All output should appear on a single line, but separate each even integer with a comma and a space. Be sure the integer 20 (which is the last expected number you'll output) omits the trailing comma and space.

Explanation / Answer

Answer)

public class EvenThough{

public static void main(String []args){

int i=1; // Starting from i = 1
while(i<=20){ // Loop till 20
if(i%2 == 0){ // Check remainder of i till 20. Check for even number
System.out.print(i); // print the number which is even
if(i<20){ // For printing the commas. It will skip the printing of comma after the last integer
System.out.print(",");
}
}
i++;
}

}
}

Output: