PrintNumber.java

/******************************************************************************
 *  Compilation:  javac PrintNumber.java
 *  Execution:    java PrintNumber
 *  
 *  Print the integers from 100 to 200, 5 per line.
 *
 *  % java PrintNumber
 *
 ******************************************************************************/

public class PrintNumber { 

    public static void main(String[] args) {

        // print integers from 1000 to 2000, 5 per line
        int START = 100;
        int END   = 200;
        int PER_LINE = 5;
        for (int i = START; i <= END; i++) {
            System.out.print(i + " ");
            if ((i + 1) % PER_LINE == 0) System.out.println();
        }
        System.out.println();
    }
}

 

posted @ 2018-09-17 16:40  盆古  阅读(474)  评论(0编辑  收藏  举报