Question: Examine the following code. Replace the stars ****** inside the catch() condition with the correct following exception type. Exception ArrayIndexOutOfBoundsException InputMismatchException What I have so

Examine the following code. Replace the stars ****** inside the catch() condition with the correct following exception type. Exception ArrayIndexOutOfBoundsException InputMismatchException

What I have so far:

import java.util.*;

/** * Enter JavaDoc Class information here * Include a description of what this class does!!! * Make sure you include your full name * Filename: MultipleCatch.java */

public class MultipleCatch {

/** * Enter JavaDoc method comment here * */ public static void main(String[] args) { Scanner input = new Scanner(System.in); double[] grades = new double[6]; int i = 0; System.out.println("Please enter up to 6 grades, enter -1 to stop."); do { try { System.out.println("Please enter a grade:"); double dblIn = input.nextDouble(); if (dblIn == -1) break; grades[i] = dblIn; i++; } catch ( ************* e) { input.nextLine(); System.out.println("Invalid input. Please enter a whole number."); } catch ( ************** e) { System.out.println("Too many grades entered, " + "the last one won't be counted"); break; } } while (true); System.out.printf("The sum of the %d grades is %.2f, the average is %.2f ", i,sumArray(grades),(sumArray(grades) / i));

} // end main class

/** * Enter JavaDoc method comment here * */ public static double sumArray(double[] dblArrIn) { double sum = 0.0; for (double dblNum : dblArrIn) { sum += dblNum; } return sum; } } // end Class MultipleCatch

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!