Checking to see whether a triangle is obtuse isosceles or acute isosceles.

obtuse: any two side lengths where the sum of their squares is less than the square of the other side length

right: any two side lengths where the sum of their squares is equal to the square of the other side length

acute: a triangle is an acute triangle if it is neither a right triangle nor an obtuse triangle

isosceles : any two sides are the same length

if ((Side1 == Side2 || Side1 == Side3 || Side2 == Side3) &&

((Math.pow(Side1,2) + Math.pow(Side2,2)) < Math.pow(Side3,2) ||

(Math.pow(Side3,2) + Math.pow(Side1,2)) < Math.pow(Side2,2) ||

(Math.pow(Side3,2) + Math.pow(Side2,2)) < Math.pow(Side1,2) ))

{

return "obtuse isosceles" ;

}

if ((Side1 == Side2 || Side1 == Side3 || Side2 == Side3) &&

((Math.pow(Side1,2) + Math.pow(Side2,2)) > Math.pow(Side3,2) ||

(Math.pow(Side3,2) + Math.pow(Side1,2)) > Math.pow(Side2,2) ||

(Math.pow(Side3,2) + Math.pow(Side2,2)) > Math.pow(Side1,2)))

{

return "acute isosceles" ;

Am I atleast on the right track? Can you help me fix it? Can you interpret the code I wrote. Like for the first one, the program checks to see whether it's an isosceles ((Side1 == Side2 || Side1 == Side3 || Side2 == Side3) is this correct? And then it checks to see whether the sum of the two squared sides is less than the other squared side &&

((Math.pow(Side1,2) + Math.pow(Side2,2)) < Math.pow(Side3,2) ||

(Math.pow(Side3,2) + Math.pow(Side1,2)) < Math.pow(Side2,2) ||

(Math.pow(Side3,2) + Math.pow(Side2,2)) < Math.pow(Side1,2) ))

is that correct. I'm having trouble understanding this if else stuff. Can you think of a more efficient way of testing to see whether the triangle is obtuse/acute?

Re: Checking to see whether a triangle is obtuse isosceles or acute isosceles.

Hi michael305rodri ,

I tried the posted code, and its working fine, you are on the right track.

the first bracket in the if condition checks whether the 2 sides are same and second brackets checks for sum of square.

result of first bracket condition is ANDed with result of second bracket condition which decides the type of triangle.