
/*

   	Tom DeDonno

	Generates a Divide By Zero Exception

	Modifies DivideByZero by adding another exception TidalWave
	TidalWave Hits when use enters a number greater than 1000.0
        
        No secondChance this time
	
 */

public class DivideByZero1 {
  
  
        public class DivideByZeroException extends Exception {
          
          public DivideByZeroException( ) { super( "Dividing by Zero" ); }
          
          public DivideByZeroException( String message ) {
            super( message );
          }
        } //End class DivideByZeroException

	public class TidalWaveException extends Exception {

		public TidalWaveException( ) {
			super( "Tidal Wave Exception Thrown" );
		}

		public TidalWaveException( String message ) {
			super( message );
		}

	} // End of Class TidalWaveException
	
	private int numerator, denominator;
	private double quotient; // Q = N/D Notre/Dame

	private int prompt( String comment ) {

		System.out.println( comment );
		return( SavitchIn.readLineInt() );
		}

	private void read( ) {

		numerator = prompt( "Enter Numerator" );
		denominator = prompt( "Enter Denominator" );
	}
	
	private void print( ) {
		
		quotient = numerator/(double)denominator;
		System.out.println( numerator + "/" +
		denominator + "=" + quotient );
	}
	
	private void doIt( ) {

		try {

			read( );
			if( denominator == 0 )
				throw new DivideByZeroException( );
			if( denominator > 1000 || numerator > 1000 )
				throw new TidalWaveException( );
			print( );	
		} catch( Exception e ) {
			System.out.println( "Message->" + e.getMessage() + "<-");
		}
		System.out.println( "End of Program." );
	} //end do It
	
	
	public static void main( String[] args ) {

		DivideByZero1 oneTime = new DivideByZero1();

		oneTime.doIt();
		}
}
		
		

