-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoubleException.java
More file actions
27 lines (26 loc) · 912 Bytes
/
DoubleException.java
File metadata and controls
27 lines (26 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.*;
public class DoubleException{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
try{
System.out.println("Enter the Size of Array: ");
int arrSize = s.nextInt();
int[] arr = new int[arrSize];
System.out.println("Enter the array location you want to Use: ");
int arrLoc = s.nextInt();
arr[arrLoc] = 0;
System.out.println("Enter value1: ");
int a = s.nextInt();
System.out.println("Enter value2: ");
int b = s.nextInt();
int c = a / b;
System.out.println(c);
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println("ArrayIndexOutOfBoundsException");
}
catch(ArithmeticException e){
System.out.println("ArithmeticException");
}
}
}