/*
   An example of nested loops.

   This version prints out a "checkerboard" pattern, and the
   even and odd rows do have the same length (change the space
   to some other character to see this). But this version is
   not as simple as it could be.
*/

public class CheckerBoard3
{
   public static void main( String[] args )
   {
      final int NUMBER_OF_COLUMNS = 16;
      final int NUMBER_OF_ROWS = 8;
      final int EVEN_CASE = 0;
      final int ODD_CASE = 1;

      int evenOrOddRow;
      int columnCounter;
      int rowCounter;

      rowCounter = 0;
      while (rowCounter < NUMBER_OF_ROWS) // a counting loop
      {
         if (rowCounter % 2 == 0)  // check for an even or odd row
            evenOrOddRow = EVEN_CASE;
         else
             evenOrOddRow = ODD_CASE;
         columnCounter = 0;
         while (columnCounter < NUMBER_OF_COLUMNS) // another counting loop
         {
            if (columnCounter % 2 == evenOrOddRow )
               System.out.print("*");
            else
               System.out.print(" ");
            columnCounter++;
         }
         System.out.println(); // start a new line
         rowCounter++;
      }
   }//main()
}