-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ3.java
37 lines (35 loc) · 889 Bytes
/
Q3.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
package Assignment;
import java.util.Scanner;
class MarksOutOfBoundException extends Exception{
MarksOutOfBoundException(String s){
super(s);
}
}
class student{
String name;
int mark;
student(String name, int mark) {
name="gopal";
mark=this.mark;
}
}
public class Q3 {
public static void main(String[]args) {
Scanner sc=new Scanner(System.in);
System.out.println("enter the mark");
if(x>100) {
try {
int x=sc.nextInt();
student sc1= new student("gopal", x);
if (sc1.mark>100){
throw new MarksOutOfBoundException("Too high");
}
}
catch(MarksOutOfBoundException ob) {
System.out.println(ob.getMessage());
}
}
else
System.out.println("Mark is "+x);
}
}