60 515
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #9101 in Java | JSP | JSF for tarik

Question #9101
write a java application that prints all even numbers from 2 to 50, with the aid of the following specification: start a new line after every multiple of 20.
Use for loop.
Save this program as evennums.java
Expert's answer
public class Main {
public static void main(String[] args)
{
System.out.print("Even numbers from 2 to 50 are: ");
for(int
i=2;i<=50;i++){
if(i%2==0){
System.out.print(i+",");
}
if(i%20==0){
System.out.print("\n");
}
}
}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions