-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqb96.java
More file actions
33 lines (29 loc) · 742 Bytes
/
qb96.java
File metadata and controls
33 lines (29 loc) · 742 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
//QB-96
import java.util.*;
class MyException extends Exception {
MyException(String s) {
super(s);
}
}
class Exceptiondemo {
void compute(int a) throws MyException {
if (a % 7 == 0 & a % 5 != 0) {
throw new MyException(a + " is divisible by 7 and not divisible by 5");
} else {
System.out.println("Invalid");
}
}
}
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a: ");
int a = sc.nextInt();
Exceptiondemo ed = new Exceptiondemo();
try {
ed.compute(a);
} catch (MyException e) {
System.out.println(e);
}
}
}