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 trialJannung Kusdiantoro
6,743 Pointsplease correct me
here is my code, what did i do wrong?
namespace Treehouse.CodeChallenges
{
class FrogStats
{
public static double GetAverageTongueLength(Frog[] frogs)
{
int total = 0;
for (int i = 0; i < frogs.Length ; i++)
{
total = total + frogs[i].TongueLength;
}
double okedeh = double.Parse(total/frogs.Length)
return okedeh;
}
}
}
namespace Treehouse.CodeChallenges
{
public class Frog
{
public int TongueLength { get; }
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
}
}
1 Answer
Steven Parker
231,236 PointsThe function double.Parse is only for converting strings to numbers.
Here, you already have numbers, so you just need to perform your calculation. To covert an int to a double, you can apply a cast:
double okedeh = (double)total/frogs.Length;