-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathExp05.java
More file actions
46 lines (38 loc) · 733 Bytes
/
Copy pathExp05.java
File metadata and controls
46 lines (38 loc) · 733 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.io.*;
import java.util.*;
class MarksOutOfRangeException extends Exception
{
public String toString()
{
return "java.lang.MarksOutOfRangeException";
}
}
class Exp05
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter Marks ");
int m = sc.nextInt();
try
{
if( (m < 0) || (m > 100) ) throw new MarksOutOfRangeException();
else
System.out.println("Marks Entered Successfully");
}
catch(Exception e)
{
System.out.println(e);
}
}
}
/* OUTPUT - 1
*
*Enter Marks
75
Marks Entered Successfully */
/* OUTPUT - 2
*
*Enter Marks
120
java.lang.MarksOutOfRangeException */