Practice1 Program
Description
This program inputs three integers: numerator, denominator, and index of an array, then uses exception handling techniques to handle several possible exceptions: InputMismatchException, ArithmeticException, and ArrayIndexOutOfBoundsException.If no exception occurred, the program prints the quotient, the remainder, and the addition stored at the given array index.
Associated Concepts:
Exception Handling
Algorithm:
main method:
Input three integers, numerator, denominator, and index of an array,
If no exception occurred, the program prints the quotient, the remainder, and the addition stored at the given array index.
If the user entered an invalid integer, the try block terminates immediately, and the program execution jumps to the matching catch block to handle the InputMismatchException.
If the user entered zero as the denominator, the try block terminates immediately, and the program execution jumps to the matching catch block to handle the ArithmeticException.
If the user entered an invalid array index, the try block terminates immediately, and the program execution jumps to the matching catch block to handle the ArrayIndexOutOfBoundsException.
The last catch block is to use the superclass object Exception to handle any unexpected exceptions.
The finally block is executed regardless.
If no exception occurred, the program prints the quotient, the remainder, and the addition stored at the given array index.
If the user entered an invalid integer, the try block terminates immediately, and the program execution jumps to the matching catch block to handle the InputMismatchException.
If the user entered zero as the denominator, the try block terminates immediately, and the program execution jumps to the matching catch block to handle the ArithmeticException.
If the user entered an invalid array index, the try block terminates immediately, and the program execution jumps to the matching catch block to handle the ArrayIndexOutOfBoundsException.
The last catch block is to use the superclass object Exception to handle any unexpected exceptions.
The finally block is executed regardless.