What type of exception is thrown if the user enters a 0 for the divisor?

A good answer might be:

An ArithmeticException.

Example Output

Here is a part of the program:

  public static void main ( String[] a )  throws IOException
  {
    try
    {
      System.out.println("Enter the numerator:");
      . . . .
      System.out.println("Enter the divisor:");
      . . . .
      System.out.println( num + " / " + div + " is " + (num/div) );
    }

    catch (NumberFormatException ex )
    {
      System.out.println("You entered bad data." );
      System.out.println("Run the program again." );
    }

    catch (ArithmeticException ex )
    {
      System.out.println("You can't divide " + num + " by " + div);
    }

Here is some sample output:

C:>java  DivisionPractice
Enter the numerator:
Rats
You entered bad data.
Run the program again.

C:>java  DivisionPractice
Enter the numerator:
12
Enter the divisor:
6
12 / 6 is 2

C:>java  DivisionPractice
Enter the numerator:
12
Enter the divisor:
0
You can't divide 12 by 0

QUESTION 14:

If an IOExeption occurs in the try{} block, what happens? (You may wish to review how try/catch blocks work.)