// Project: Loops // Module: counting // Source code file: Main.java // Count to 100 using while and for loops. // Also count backwards from 100 to 1 by 7s. public class Main { public static int LINE_SIZE = 30; public static void main(String[] args) { // Count to 100 with while loop. int n = 1; while (n <= 100) { System.out.print(n + " "); if (n % LINE_SIZE == 0) { System.out.println( ); } n++; } System.out.println("\n"); // Count to 100 with for loop. for(n = 1; n <= 100; n++) { System.out.print(n + " "); if (n % LINE_SIZE == 0) { System.out.println( ); } } System.out.println("\n"); // Count backwards from 100 by 7s. for(n = 100; n >= 1; n -= 7) { System.out.print(n + " "); } } }