Class ExceptionsDemo1a

java.lang.Object
  extended by ExceptionsDemo1a

public class ExceptionsDemo1a
extends java.lang.Object

Validating that both inputs are integers and the denominator is not zero an using the InputMismatchException, ArithmeticException and RuntimeException classes.

Version:
Copyright (c) 2002 -- SCCC West
Author:
Prof. Carl B. Struck

Constructor Summary
ExceptionsDemo1a()
           
 
Method Summary
static void main(java.lang.String[] args)
          Input two 'int' variables, calculate and display the quotient of the division operation.
static int quotient(int numerator, int denominator)
          Performs division with the numerator and denominator parameters and returns the quotient.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionsDemo1a

public ExceptionsDemo1a()
Method Detail

main

public static void main(java.lang.String[] args)
Input two 'int' variables, calculate and display the quotient of the division operation. Validates user input with exception classes InputMismatchException, ArithmeticException and RuntimeException.

Parameters:
args - The String[] array command line parameter
Throws:
java.util.InputMismatchException - if numerator or denominator are not integers
java.lang.Exception - handles any unexpected exceptions

quotient

public static int quotient(int numerator,
                           int denominator)
Performs division with the numerator and denominator parameters and returns the quotient.

Parameters:
numerator - The dividend of the division operation
denominator - The divisor of the division operation
Returns:
The result of the division operation
Throws:
java.lang.ArithmeticException - if denominator is zero (0)