/**  SquaresLoop:     Simple to print out a range of numbers
 *                    and their square in a for loop
 *
 */

import uk.ac.ed.ph.sciprog.*;                  // Import Display classes


public class SquaresLoop{                       // Define main class
    public static void main(String args[]){     // main program start

	//                 Setup the Display 
	
	Display panel = new Display("Squares Loops");
	Input maxInput = new Input("Maximum square", 10);
	panel.addInput(maxInput);           // Add to display

    //                  Loop ``for ever'' reading + writing   
    //                 
	while( true ){
	panel.waitForButtonPress();

	int maxValue = maxInput.getInt();                   // Read the integer
	
	//            for loop to print out the numbers

	for(int i = 0; i <= maxValue; i++) {
	    panel.printf("The square  of %d is %d\n" , i, i*i);
	}
	
	panel.println();                                // blank line  
	}                                               // end of while loop

                            
  }
}
