-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangleClassifier.java
More file actions
43 lines (33 loc) · 1.23 KB
/
Copy pathTriangleClassifier.java
File metadata and controls
43 lines (33 loc) · 1.23 KB
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
import java.util.Scanner;
public class TriangleClassifier{
public static String classifyTriangle(int a, int b, int c){
// Upper limit check for each side
if (a > 10 || b > 10 || c > 10) {
return "Invalid: Sides should be <= 10";
}
if (a + b > c && b + c > a && c + a > b){
if (a == b && b == c){
return "Equilateral";
} else if (a == b || b == c || c == a){
return "Isosceles";
} else {
return "Scalene";
}
} else {
return "Not a Triangle";
}
}
public static void main (String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the sides of the triangle:");
System.out.print("Side 1: ");
int a = scanner.nextInt();
System.out.print("Side 2: ");
int b = scanner.nextInt();
System.out.print("Side 3: ");
int c = scanner.nextInt();
String result = classifyTriangle(a, b, c);
System.out.println("Sides: (" + a + "," + b + "," + c + ") => Result: " + result);
scanner.close();
}
}