Computer Science, asked by sonu1592, 1 year ago

write a program in java to input the sides of a triangle. pass the sides to a function decide (int x, int y, int z) which checks and print whether the triangle is equilateral, isosceles or scalene

Answers

Answered by 1Rubin1
112
import java.util.*;
class tri
{
          public static void main()
        {
               Scanner s = new Scanner(System.in);
               System.out.println("Enter three sides of triangle");
               int a = s.nextInt();
               int b = s.nextInt();
               int c = s.nextInt();
               triangle_type(a,b,c);
                                             }
               static void triangle_type(int x,int y,int z)
              {
                    if(x==y&&y==z)
                    System.out.println("Triangle is equilateral");
                    else if(x==y||y==z||z==x)
                    System.out.println("Triangle in isosceles");
                    else
                    System.out.println("Triangle is scalene");
                                               }
}
Answered by tanishqverma26jul200
10

Answer:

class abc

{

       public static void main(int x , int y , int z)

{

System.out.println("First side = "+x);

System.out.println("Second side = " +y);

System.out.println("Third Side="+z)';

if((x==y) && (y==z))

{

System.out.println("The triangle is Equilateral.);

}

else if((x==y) || (y==z) || (z==x))

{

System.out.println("The triangle is Isosceles");

}

else

{

System.out.println("The traingle is Scalene.");

}}}

Explanation:

Mark my answer as the brainliest.

Similar questions