Pythagorean Theorem Download

Christina Cacioppo

doubles, variables, functions Student approved


An old piece of math is the Pythagorean Theorem, which relates the lengths of the three sides of a right triangle: the sum of the two leg lengths, squared, is equivalent to the hypotenuse's length, squared: a2 + b2 = c2.

So if you know the length of each of the triangle's legs (a, b), the hypoteneus' length, c, is square root[a2 + b2]


Complete the calcHypotenous function.

The function takes two parameters, double a and double b, which you'll want to use in the equation. Your function should return the triangle's hypotenous.

Starter code

class Pythag{
	public static void main(String[] args){
		double hyp = calcHypotenuse(3, 4);

	static double calcHypotenuse(double a, double b){
		double c = //something
		return c;

Expected output



Useful tools to solve the problem