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 trialAmit Ghosh
9,314 PointsIs there anything wrong with my code
Please check , I am returning a double
using System;
namespace Treehouse.CodeChallenges
{
class RightTriangle
{
public static double CalculateHypotenuse ( double x , double y)
{
return (double)Math.Sqrt(Math.Pow(x,2) + (Math.Pow(y,2));
}
}
}
1 Answer
andren
28,558 PointsYou have an unnecessary opening parenthesis in your code, right before "Math.Pow(y,2)". If you remove it like this:
using System;
namespace Treehouse.CodeChallenges
{
class RightTriangle
{
public static double CalculateHypotenuse ( double x , double y)
{
return (double)Math.Sqrt(Math.Pow(x,2) + Math.Pow(y,2));
}
}
}
Then your code will pass. Though it's also worth mentioning that casting the result of "Math.Sqrt" to double is redundant and unnecessary, since that function returns a double on its own.