// Nested For Loop Demo with a Grid, M.S. Branicky, 09/19-20/2007 public class Grid { public static void main (String[] args) { int i, j; for (i=1; i<=31; i++) { for (j=1; j<=89; j++) { if ((i%2==0) && (j%2==0)) { System.out.print(" "); } // end if both even else { if ((i%2==1) && (j%2==1)) { System.out.print("+"); } // end if of both odd else { if (i%2==1) { System.out.print("-"); } else { System.out.print("|"); } } // end else of both odd } // end else of both even } // end for (j) System.out.println(); } // end for (i) } // end main } // end class