Triangle Inequality Theorem and Triangle Classification

This program will take 3 side lengths input by a user and then determine if those sides can form a triangle. The Triangle Inequality Theorem states that the sum of any two side lengths in a triangle must be greater than the third side.

If the three sides can form a triangle, the triangle will be classified as acute (all three angles are less than 90 degrees), right (one of the angles is 90 degrees, the other two are acute), or obtuse (one of the angles is greater than 90 degrees and the other two are acute). The Pythagorean Theorem states that in a right triangle, the square of the longest side (the hypotenuse) is equal to the sum of the squares of the other two sides. If the longest side squared of any triangle is bigger than the sum of the squares of the other two sides (i.e. bigger than it needs to be to make a right triangle), then the triangle must be obtuse. If the longest side squared is smaller than the sum of the squares of the other two sides (i.e. smaller than it needs to be to make a right triangle), then the triangle must be acute. If the longest side squared is equal to the sum of the squares of the other two sides, then the triangle must be a right triangle.

If 2 sides are equal in length the triangle will be classified as isosceles. If all 3 sides are equal in length the triangle will be classified as equilatereal. Finally, if none of the sides are equal in length, the triangle will be classified as scalene.

The 3 angles will be calculated in degrees using the Law of Cosines.

The area of the triangle will be calculated using Heron's Formula. Heron's formula uses the three side lengths only and the semi-perimeter s = the perimeter divided by 2, i.e. (a + b+ c)/2. Area = sqrt(s*(s-a)(s-b)(s-c)). Note that a property of the semi-perimeter is that it is always longer than any side length.

This program is written in JavaScript.

By Mr. C. January, 2020

*********************results********************************

To check your answers, or to get more ideas to program, visit:
Triangle-calculator.com