lordzee - 1 year ago 65

Java Question

I made a program that asks the user for 3 lengths and determines if it is equilateral,scalene, isosceles. I want to know how to calculate angles(all 3 sides are given) in Java so that the program determines if it is obtuse or acute or right-angled.Please help me out.

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

As you know the sides of the triangle, you can find the angles just by following steps below...

- use The Law of Cosines first to calculate one of the angles
- then use The Law of Cosines again to find another angle
- and finally use angles of a triangle add to 180° to find the last angle.

In java you can use `Math.acos(val)`

to calculate the Inverse Cosine.

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**