-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhand.java
40 lines (32 loc) · 1.15 KB
/
hand.java
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
33
34
35
36
37
38
39
40
package com.company;
import java.util.Scanner;
public class hand {
public static void main(String[] args) {
int[] marks = new int[5];
marks[0] = 2;
marks[1] = 3;
marks[2] = 5;
Scanner sc = new Scanner((System.in));
System.out.println("enter index for array");
int x = sc.nextInt();
System.out.println("enter number to divide it");
int y = sc.nextInt();
try {
System.out.println("hello");
try {
System.out.println("value at entered index is" + marks[x]);
System.out.println("division by " + y + " is :" + marks[x] / y);
} catch (ArithmeticException e) {
System.out.println(" ArithmeticException occured");
System.out.println(e);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println(" ArrayIndexOutOfBoundsException occured");
System.out.println(e);
}
}
catch (Exception e) {
System.out.println(" some excetion occured");
System.out.println(e);
}
}
}