CheckerBoard.java


Below is the syntax highlighted version of CheckerBoard.java.


/************************************************************** 
 * Compilation:  javac-introcs CheckerBoard.java
 * Execution:    java-introcs CheckerBoard N
 * Dependencies: StdDraw.java
 *
 * Plots an NxN red and black checkerboard. 
 * Lower left square is red.                    (Ex. 1.5.18)
 **************************************************************/

public class CheckerBoard { 

    public static void main(String[] args) {
        // declaration and initialization - How big?
        int N = _____________________________________
        StdDraw.setXscale(0, N);
        StdDraw.setYscale(0, N);

        // Draw from lower left, up and across
        // i is the index for the x value.  j is the index for y.
        for (int i = 0; i < N; i++) {
            for (int j = 0; __________; _________) {
                if ( ((i+j) % 2) ______________ ) 
                     StdDraw.setPenColor(StdDraw.BLACK);
                else StdDraw.___________________(StdDraw.___________);
                StdDraw.filledSquare(___________, ___________, 0.5);
            }
        }
        
        StdDraw.show();
    }
}