
Write a Java program to input the sides of a triangle. Pass the sides to a function decide(int x,int y,int z) which checks and prints whether the triangle is equilateral,isosceles or scalene.

The given code accepts the sides of triangle from the user. Pass the sides to a function decide(int x,int y,int z) which checks and prints whether the triangle is equilateral,isosceles or scalene.
import java.util.*;
class TypeOFTriangle
{
public static void decide(int side1,int side2,int side3){
String type="";
if(side1 == side2 && side2 == side3){
type = "Equilateral";
}
else if(side1 == side2 && side2 != side3){
type = "Isosceles";
}
else if(side1 == side3 && side2 != side3){
type = "Isosceles";
}
else if(side1 != side3 && side2 == side3)
type = "isosceles";
else
type = "Scalene";
System.out.println(type);
}
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter side 1: ");
int side1=input.nextInt();
System.out.print("Enter side 2: ");
int side2=input.nextInt();
System.out.print("Enter side 3: ");
int side3=input.nextInt();
decide(side1,side2,side3);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.