Computer Science, asked by raturivaibhav40, 7 months ago

Write a program to input three sides of a triangle using Scanner class and check
whether triangle will be formed or not. If possible then print what type of triangle
it is : Equilateral, Isosceles or Scalene.​

Answers

Answered by anindyaadhikari13
2

Question:-

Write a program to input three sides of a triangle using Scanner class and check whether triangle will be formed or not.

If possible, then print what type of triangle it is: Equilateral, Isosceles or Scalene.

Code:-

class Triangle

{

public static void main(double a, double b, double c)

{

if(a+b>c&&b+c>a&&a+c>b)

{

System.out.println("Triangle is possible.");

if(a==b &&b==c)

System.out.println("Given triangle is an Equilateral Triangle. ");

else if(a==b || b==c || a==c)

System.out.println("Given triangle is an Isosceles Triangle.");

else if(a!=b&&b!=c&&c!=a)

System.out.println("Given triangle is a Scalene Triangle.");

}

else

System.out.println("Triangle is not possible.");

}

}

Similar questions