Write a java application that prints all even numbers from 2 to 50 with the aid specifications:
*start new line after every multiple of 20.
*use for loop.
1
Expert's answer
2011-06-01T13:25:41-0400
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; }; }; }; };
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment