Pythagoras Theorem

Java 13.12.2010 No Comments

In any right triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).

Pythagoras Theorem, Wikipedia

One of our member students was asked to implement the Pythagoras Theorem using Java. This is a good opportunity to introduce the Math class which contains a collection of static methods for various mathematical functions.

We need the square root method (sort) to calculate the hypotenuse, and can also use the pow() method to calculate the base.

The Java code showing the use of the Pythagoras Theorem and Math class for calculating the length of triangle sides is available for download by members only. Java mentors are also available to answer any questions you have about the solution.x

Leave a Reply

s2Member®