import java.util.*;

public class ForExamples {
  public static void main(String[] args) {
    System.out.println("Here is the result of 6 print statements:");
    
    System.out.println(1 + " squared is " + (1 * 1));
    System.out.println(2 + " squared is " + (2 * 2));
    System.out.println(3 + " squared is " + (3 * 3));
    System.out.println(4 + " squared is " + (4 * 4));
    System.out.println(5 + " squared is " + (5 * 5));
    System.out.println(6 + " squared is " + (6 * 6));
    
    System.out.println("\nHere is the result of a for loop:"); 
    
    int count;
    // count from 1 to 6
    for (count = 7; count <= 11; count++) {
      // print a line using the current value of count
      System.out.println(count + " squared is " + (count * count));
    }
    
    System.out.println("\nAnother for loop prints the squares on one line:"); 
    // print the numbers on one line
    for (count = 1; count <= 6; count++) {
      // print count squared
      int squared = count * count;
      System.out.print(squared + ",");
      System.out.print(" ");
    }
    System.out.println();
    
    System.out.println("\nThese are the results of for loop variations:");
    
    // Declare the control variable (i in this example) in the initialization.
    // prints 1 2 3 4 5 6
    for (int i = 1; i <= 6; i++) {
      System.out.print(i + "\t");
    }
    System.out.println();
    
    for (int i = 1; i <= 6; i += 2) {  // i += 2 is equiv. to i = i + 2
      System.out.print(i + "\t");
    }
    System.out.println();
    
    // print each number 13 times on separate lines
    for (int i = 1; i <= 6; i++) {
      // print one line
      for (int j = 1; j <= 13; j++) {
        System.out.print(j);
      }
      System.out.println();
    }
    
    // Another way to perform a certain number of iterations is to start 
    // counting at 0 and then go up to but not including the number of iterations.
    // prints $$$$$$$$$$
    for (int j = 0; j < 10; j++) {
      System.out.print("$&");
    }
    System.out.println();
    
    // To count down, decrement the control variable in the update, 
    // and use > or >= in the test.
    // prints 10 9 8 7 6 5 4 3 2 1 Lift off!
    for (int k = 10; k > 0; k--) {
      System.out.print(k + " ");
    }
    System.out.println("Lift off!");
    
  }
}






