/*******************************************************************
** This application is an illustration of an Exception throws an excetion
********************************************************************/
import java.io.*;
import java.lang.*;


public class ExceptionThrowsException
{
  final int   ZERO = 0;
  int         ExecutionCount = 0;

  public ExceptionThrowsException()
  {
    ExecutionCount++;
    System.out.println(ExecutionCount
               + ")*** The start of ExceptionThrowsException Constructor****");
    try
    {
      ExecutionCount++;
      System.out.println(ExecutionCount
                  + ")***  Start of Try Constructor Clause  ****");
      Method_1(0);
    }
    catch (IOException  MyIOException)
    {
      ExecutionCount++;
      System.out.println(ExecutionCount
             + ")*** Start of IOException Constructor catch Clause  ****");
    }
    catch (IndexOutOfBoundsException  MyIndexOutOfBoundsException)
    {
      ExecutionCount++;
      System.out.println(ExecutionCount
          + ")*** Start of IndexOutOfBoundsException Constructor catch Clause  ****");
    }
    ExecutionCount++;
    System.out.println(ExecutionCount
               + ")*** The end of ExceptionThrowsException Constructor****");
  }
  //**********************************************
  float ExceptionMethod(int PassedInteger)
        throws ArithmeticException
  {
    ExecutionCount++;
    System.out.println(ExecutionCount
                  + ")***  The start of ExceptionMethod   ****");
    if(0 == PassedInteger)
      throw new ArithmeticException();
    ExecutionCount++;
    System.out.println(ExecutionCount
                  + ")***  End of ExceptionMethod ****");
    return (PassedInteger);
  }  // ExceptionMethod
  //**********************************************
  void Method_1(int IntegerValue)
        throws IOException,
               IndexOutOfBoundsException
  {
    float       FloatValue   = -20;

    ExecutionCount++;
    System.out.println(ExecutionCount
                  + ")***  The start of Method_1   ****");
    ExecutionCount++;
    System.out.println(ExecutionCount
                  + ")FloatValue = \t" + FloatValue);
    try
    {
      ExecutionCount++;
      System.out.println(ExecutionCount
                  + ")***  Start of Method_1 Try Clause  ****");
      FloatValue = ExceptionMethod(IntegerValue);
    }
    catch (ArithmeticException  MyArithmeticException)
    {
      ExecutionCount++;
      System.out.println(ExecutionCount
                  + ")*** Start of ArithmeticException catch Clause  ****");
      throw new IndexOutOfBoundsException();
    }
    finally
    {
      ExecutionCount++;
      System.out.println(ExecutionCount
                  + ")*** Start of Method_1 finally clause  ****");
      throw new IOException();
    }
/*************
** Statments not reachable error and we have to comment them
    ExecutionCount++;
    System.out.println(ExecutionCount
                  + "**** After Method_1 finally Block *****");
    ExecutionCount++;
    System.out.println(ExecutionCount
                  + ")FloatValue = \t" + FloatValue);
****/
  } // Method_1
  /****************************************************/
  public static void main(String [] args)
  {
    ExceptionThrowsException  MyExceptionThrowsException
          = new ExceptionThrowsException();
	try
	{
		System.in.read();
	}
	catch(Exception myException)
	{// do nothing
	}
  }
}
