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
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
Math,
3 months ago
Social Sciences,
3 months ago
English,
3 months ago
Geography,
7 months ago
Chemistry,
1 year ago