/**
   From class, Thursday, October 8, 2015.
*/

public class TestLoops_ver2
{
   public static void main(String[] args)
   {
      // 1
      for (int i = 1; i <= 100; i++)
      {
         System.out.print(i + " ");
         if ( i % 10 == 0 )
         {
            System.out.print("\n");
         }
      }


      System.out.println("\n");


      // 2
      for (int i = 1; i <= 100; i++)
      {
         if ( (i-1) % 10 == 0 )
         {
            System.out.print("\n");
         }
         System.out.print(i + " ");
      }


      System.out.println("\n");


      // 3
      int i = 1;
      for (int row = 0; row < 10; row++)
      {
         for (int col = 0; col < 10; col++)
         {
            System.out.print( i++ + " " );
         }
         System.out.println();
      }


      System.out.println("\n");


      // 4
      for (int row = 0; row < 10; row++)
      {
         for (int col = 0; col < 10; col++)
         {
            // we can use either one of the following two lines
            System.out.print( (row * 10) + col + " " );
          //System.out.print( row + (col + " ") );
         }
         System.out.println();
      }


      System.out.println("\n");


      // 5
      // Notice how, in the last example, the number 10 appears three times.
      // Those three 10's are not all the "same" 10, they play different
      // roles in the code. One 10 means "number of rows" and the other
      // two 10's mean "number of columns". We should use named constants
      // instead of "magic numbers" in order to make clear the use of
      // each number.
      // Try changing the values of these three constants.
      final int NUMBER_OF_COLUMNS = 10;
      final int NUMBER_OF_ROWS    = 10;
      final int STARTING_NUMBER   =  1;
      for (int row = 0; row < NUMBER_OF_ROWS; row++)
      {
         for (int col = 0; col < NUMBER_OF_COLUMNS; col++)
         {
            System.out.print( (STARTING_NUMBER + (row * NUMBER_OF_COLUMNS) + col) + " " );
         }
         System.out.println();
      }

   }//main()
}
