Problem

TestExceptions:What does this program output? Because this program converts between string...

TestExceptions:

What does this program output? Because this program converts between string and numeric values, use quotes to denote string values.

/************************************************************** TestExceptions.java* Dean & Dean** This looks up the value at a calculated index.*************************************************************/public class TestExceptions{    private double[] value =       new double[] {1.0, 0.97, 0.87, 0.7, 0.47, 0.17};    private int num;    //**********************************************************    public double eval(String n1, String n2)       throws IndexOutOfBoundsException    {       try       {         num = Integer.parseInt(n1) / Integer.parseInt(n2);       }       catch (NumberFormatException nfe)       {         num++;         System.out.println("in first catch");       }       catch (ArithmeticException ae)       {         num++;         System.out.println("in second catch");       }       return value[num];    }    //**********************************************************    public static void main(String[] args)    {       TestExceptions te = new TestExceptions();       try       {          System.out.println(te.eval("5.0", "4"));          System.out.println(te.eval("5", "0"));          System.out.println(te.eval("22", "5"));          System.out.println(te.eval("33", "5"));       }       catch (Exception e)       {          System.out.println("in main’s catch");       }       System.out.println("Bye");    } // end main} // end TestExceptions class

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 15
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT