64 634
Assignments Done
99,1%
Successfully Done
In September 2018

Answer to Question #2851 in Java | JSP | JSF for thusang

Question #2851
Write a java application that prints all even numbers from 2 to 50 with the aid specifications:<br>*start new line after every multiple of 20. <br>*use for loop.
Expert's answer
class PrintEvenNumbers
{
public static void main(String[] args)
{
int x=2;
for (int i=2; i<=50; i+=2)
{
System.out.print(i+" ");
x+=2;
if (x>20)
{
System.out.println();
x=2;
};
};
};
};

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