-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomStudentsException.java
More file actions
75 lines (54 loc) · 2.09 KB
/
Copy pathCustomStudentsException.java
File metadata and controls
75 lines (54 loc) · 2.09 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.util.Scanner;
import java.util.Scanner;
class SMVDUException1 extends Exception {
public SMVDUException1(String str) {
super(str);
}
}
class SMVDUException2 extends Exception {
public SMVDUException2(String str) {
super(str);
}
}
public class CustomStudentsException {
public static void main(String args[]) throws SMVDUException1,SMVDUException2 {
Scanner sc1 = new Scanner(System.in);
Scanner sc2 = new Scanner(System.in);
System.out.println("Enter the details of the students for M.Tech ");
System.out.println("Enter Percentage: ");
int per = sc1.nextInt();
System.out.println("Enter Percentage: ");
String ugc = sc2.nextLine();
int reqper = 60;
String requgc1 = "cse";
String requgc2 = "it";
if (per<=reqper) {
try {
throw new SMVDUException1("Percentage not met");
} catch (SMVDUException1 ex) {
System.out.println(ex.getMessage());
}
} else if (per>reqper) {
try {
throw new SMVDUException2("Condition met");
} catch (SMVDUException2 ex) {
System.out.println(ex.getMessage());
}
}
else if (!(ugc.equals(requgc1) ||ugc.equalsIgnoreCase(requgc2))) {
try {
throw new SMVDUException2("Condition not met");
} catch (SMVDUException2 ex) {
System.out.println(ex.getMessage());
}
}
else if (ugc.equals(requgc1) ||ugc.equalsIgnoreCase(requgc2)){
try {
throw new SMVDUException2("Condition met");
} catch (SMVDUException2 ex) {
System.out.println(ex.getMessage());
}
System.out.println("Out Of Exception");
}
}
}