Pythagorean Theorem

Pythagorean Theorem

When solving the problems in this section, you must follow the application programming interface (API) expected in each problem. You should implement all the attributes and operations mentioned in the API.

Note that there is no main method in the APIs. That is, you should not perform any data processing within the main method. You should rather use the main method to test other methods, prompt the user for some inputs, and display the results returned by your methods. 


The Pythagorean Theorem relates the lengths of the three sides of any right triangle. The legs of a right triangle (the two sides of the triangle that meet at the right angle) are customarily labelled as having lengths “a” and “b”, and the hypotenuse (the long side of the triangle, opposite the right angle) is labelled as having length “c”. The lengths are related by the following equation: a ^2 + b^2 = c ^2.” – refer to for details.

This equation allows you to find the length of a side of a right triangle when they’ve given you the lengths for the other two sides, and, going in the other direction, allows you to determine if a triangle is a right triangle when they’ve given you the lengths for all three sides.

This equation can alternatively be written as c = sqrt of (a^2+b^2).  You can find the square root of a number by calling the standard function Math.sqrt. For example, the statement double y = Math.sqrt(x) sets y to the square root of x.

Given the right triangles described below, write a program to compute the lengths of the remaining sides using a program.

a = 48 and c = 80

a = 84 and c = 91

Determine if the following triangles are right-angled triangles:

a = 45, b = 55, and c = 75

a = 28, b = 45, and c = 53

Powered by