/**
 * Read a number and print its square.
 */
public class Square
{
  public static void main(String[] args)
  {
    foo();
  }
  public static void foo() {
    int val;
    SimpleInput eyes = new SimpleInput();
    SimpleOutput pen = new SimpleOutput();
    boolean done = false;

    String input;
    pen.print("Please enter a number: ");
    while (!done) {
      input = eyes.readString();
      try {
        val = Integer.parseInt(input);
        pen.println(val + " squared is " + (val * val));
        done = true;
      }
      catch (NumberFormatException nfe) {
        pen.println("Sorry, " + input + " is not a number I understand.");
        pen.println("Here's what my friend parseInt says: " + nfe);
        pen.print("Try again: ");
      }
    } // while
    pen.println("Wasn't that fun?");
  } // foo()
} // class Square

