-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain_81.java
More file actions
32 lines (32 loc) · 1.04 KB
/
Main_81.java
File metadata and controls
32 lines (32 loc) · 1.04 KB
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
28
29
30
31
32
import java.util.Scanner;
public class Main_81 {
public static void main(String[] args) {
int marks[]=new int[5];
marks[0]=45;
marks[1]=54;
marks[2]=67;
marks[3]=49;
marks[4]=23;
Scanner in= new Scanner(System.in);
System.out.println("Enter array index:");
int ind= in.nextInt();
System.out.println("Enter number to divide with:");
int num= in.nextInt();
try{
System.out.println("The value at index is "+ marks[ind]);
System.out.println("Array value/number is "+marks[ind]/num);
}
catch(ArithmeticException e){
System.out.println("Arithmetic exception occured");
System.out.println(e);
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println("ArrayIndexOutOfBoundsException occured");
System.out.println(e);
}
catch(Exception e){
System.out.println("Exception occured");
System.out.println(e);
}
}
}