- Exercise 2 Consider The Program Below Import Java Util Public Class Ex2 Exception Public Static Void Main String 1 (26.16 KiB) Viewed 41 times
Exercise #2: Consider the program below: import java.util.*; public class Ex2_Exception public static void main(String[]
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Exercise #2: Consider the program below: import java.util.*; public class Ex2_Exception public static void main(String[]
Exercise #2: Consider the program below: import java.util.*; public class Ex2_Exception public static void main(String[] args) { Scanner keyboard - new Scanner (System.in); int size = 10; int[] data = new int[size]; double sum=0, avg; for (int i=0; i< size; ++i) { System.out.println("Enter an integer value :"); data[1] = keyboard.nextInt(); sum - sum+data (1): avg = sum/size: System.out.println("Average: "+avg); //End of main »// End of class Rewrite the program Use Java exception handling mechanism to handle the following two types of exceptions: (0) Input MishMatchException, and () IndexOutOfBoundsException. 1