Skip to content

Commit bc838e7

Browse files
authoredOct 15, 2022
Create ExceptionOwn.java
1 parent f58f0b5 commit bc838e7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
 

‎ExceptionOwn.java

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import java.util.*;
2+
3+
class MyExp extends Exception
4+
{
5+
MyExp(String msg)
6+
{
7+
super(msg);
8+
}
9+
}
10+
class ExceptionOwn
11+
{
12+
public static void main(String args[])
13+
{
14+
Scanner sc = new Scanner(System.in);
15+
System.out.print("Input Percentage :- ");
16+
int per = sc.nextInt();
17+
18+
try
19+
{
20+
if(per < 40)
21+
{
22+
throw new MyExp("YOU ARE FAILED, LOSER!!");
23+
}
24+
else
25+
{
26+
System.out.println("YOU ARE PASSED, GOOD JOB!");
27+
}
28+
System.out.println("You Obtained " + per + "percent");
29+
}
30+
catch(MyExp e)
31+
{
32+
System.out.println(e.getMessage());
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)
Please sign in to comment.