-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlegalTriangle.java
More file actions
35 lines (29 loc) · 947 Bytes
/
Copy pathlegalTriangle.java
File metadata and controls
35 lines (29 loc) · 947 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
import java.util.Scanner;
class IllegalTriangleException extends Exception {
public IllegalTriangleException(String s) {
super(s);
}
}
public class legalTriangle {
public static void checking_triangle() throws IllegalTriangleException {
Scanner intput = new Scanner(System.in);
int x, y, z;
System.out.println("Enter x:");
x = intput.nextInt();
System.out.println("Enter y:");
y = intput.nextInt();
System.out.println("Enter z:");
z = intput.nextInt();
if ((x + y > z) && (x + z > y) && (y + z > x))
System.out.println("Yes");
else
throw new IllegalTriangleException("You can't make triangle!");
}
public static void main(String[] args) {
try {
checking_triangle();
} catch (IllegalTriangleException e) {
System.out.println("exception handled " + e);
}
}
}