TestExceptions:
What does this program output? Since 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
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.