Â
 In this, we are going to write a simple program for checking the type of triangle in Java.
import java.util.*;
class Triangle2
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int a, b, c;
System.out.println("Enter 3 sides:");
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
if (a < b + c && b < a + c && c < a + b)
{
if (a * a < b * b + c * c && b * b < a * a + c * c && c * c < a * a + b * b)
{
System.out.println("Acute angled triangle");
}
else if (a * a > b * b + c * c || b * b > a * a + c * c || c * c > a * a + b * b)
{
System.out.println("Obtuse angled triangle");
}
else
{
System.out.println("Right angled triangle");
}
}
else
{
System.out.println("Cannot form a triangle");
}
}
}
                    #ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP