import java.util.Scanner; // bring in Scanner class so we can use it

public class For
  /** This class Introduces for Loop **/
  
{
  public static void main(String[] args)
  {  
    /* general format of a for loop: 
    for (initialization; boolean expr; update)  {
    } */
    
    for (int i=0; i<5; i++) {
      System.out.println("hello world");
    }
    /********the following while loop is identical to above for loop.
    int num=0;
    while (num < 5) {  
      System.out.println("hello world");
      num++;
    }****************/
    // let's write a for loop that iterates up until the value in 
    // a variable
    int limit=10;
    for (int i=0; i<limit; i++) {
      System.out.print(i + " ");
    }
    
    // now let's read in that value
    System.out.print("\nEnter number of times to execute loop: ");
    Scanner scanner = new Scanner(System.in);
    limit=scanner.nextInt();
    /**
    for (int i=0; i<limit; i++) {
       System.out.print(i + " ");
    } **/
    
     for (int i=limit-100; i<limit; i+=10) {
       System.out.print(i + " ");
    } 
    
    /* print a table, numbers and squares (and cubes)
    example:
     1 1
     2 4
     3 9
     */
     System.out.println("About to print table of squares.");
     int start, end;
     System.out.print("\nEnter number to start with and to end with: ");
     start=scanner.nextInt();
     end=scanner.nextInt();
     System.out.println("Number  Square    Cube");
     System.out.println("======================");
     for (int i=start; i<=end; i++) {
          System.out.printf("%4d %8d %8d\n", i, i*i, i*i*i);  
     }   
  }
}