Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Loops and Final Touches Static Members

Sean Cansdale
Sean Cansdale
3,075 Points

I'm check this over a few times and I'm unable to see the problem with my solution?

public static double CalculateHypotenuse(double a, double b) { return System.Math.Pow(a, 2) + System.Math.Pow(b, 2); }

RightTriangle.cs
namespace Treehouse.CodeChallenges
{
    class RightTriangle
    {
        public static double CalculateHypotenuse(double a, double b) {
            return System.Math.Pow(a, 2) + System.Math.Pow(b, 2);
        }
    }
}

1 Answer

Steven Parker
Steven Parker
231,198 Points

Your method is calculating the sum of the squares of the two sides, but the Pythagorean Theorem says that the length of the hypotenuse would be the square root of that sum.

Sean Cansdale
Sean Cansdale
3,075 Points

Cheers! I feel a bit stupid :)