class NotNegativeInput extends Exception
{
	public NotNegativeInput()
	{
		super("Not negative input has been received...");
	}

}

public class ExceptionExample
{
	static public void main(String[] argv)
	{
		double d = 0.0;

		try
		{
			d = Double.parseDouble(argv[0]);
		}
		catch(ArrayIndexOutOfBoundsException e)
		{
			System.out.println("No argumnets. Usage: java ExceptionExample -NegativeNumber: ");
			System.out.println(e.getMessage());
			return;
		}
		catch(NumberFormatException e)
		{
			System.out.println("Invalid number format!!!");
			System.out.println(e.getMessage());
			return;
		}

		try
		{
			printResults(d);
		}
		catch(NotNegativeInput e)
		{
			System.out.println(e.getMessage());
		}
	}

	static void printResults(double d) throws NotNegativeInput
	{
		if(d >= 0.0)
			throw new NotNegativeInput();
		else
			System.out.println("Results: " + d + "*" + d + "=" + d*d);
	}
}

