// Import statement
import java.io.*;

/**
 * This class demonstrates documentation comments.
 * @author Herbert Schildt
 * @version 1.2
 */

public class SquareNum {

   /**
    * This method returns the square of the num
    * This is a multiline description you can use
    * as many lines as you like.
    * @param num The value to be squared
    * @return num squared
    */
    public double square( double num)
    {
        return num * num;
    }

   /**
    * This method inputs a number from the user.
    * @return The value input as a double
    * @exception IOException On input error.
    * @see IOException
    */
    public double getNumber() throws IOException
    {

        // Create a buffered reader using System.in
        InputStreamReader istr = new InputStreamReader (System.in);
        BufferedReader inData = new BufferedReader(istr);
        String str;

        // Read the data input on console using
        // the readLine() method of the BufferedReader class
        str = inData.readLine();
        return (new Double (str) ).doubleValue();
    }


   /**
    * The main method demonstrates square()
    * @param args Unused.
    * @return Nothing.
    * @exception IOException On input error.
    * @see IOException
    */
    public static void main( String args[]) throws IOException
    {

        // Instantiating a new object fo the SquareNumclass.
        SquareNum ob= new SquareNum();
        double val;
        System.out.println(" Enter value to be squared: ");

        // Calling the getNumber() method
        val = ob.getNumber();

        // Calling the square() method and storing it in val.
        val =ob.square(val);

        System.out.println("The squared value is " + val);
    }

}

