public void setType(int side1, int side2, int side3)
{
if((side1 == side2) && (side2 == side3) && side1+side2+side3 > 0)
{
System.out.println("EQUILATERAL");
}
else if((side1 == side2) || (side2 == side3) || (side3 == side1) && side1+side2+side3 > 0)
{
System.out.println("ISOSCELES");
}
else if(((side1 > side2+side3) && (side1 < side3 - side2 )) || (side1 < side2-side3) || (side1+side2+side3 <= 0))
{
System.out.println("DOES NOT FORM A TRIANGLE");
}
else
{
System.out.println("SCALENE");
}
}
The goal of the program is to determine the triangle type three ints create. The program is outputting ISOSCELES for int 0,0,0. Is there a certain order I need to use when combining || and && conditionals?
Aucun commentaire:
Enregistrer un commentaire