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 trialJames King
3,670 PointsI can't figure out why my answer isn't correct.
I have gone over this as many ways as I can think of and I'm still getting errors...please help me.
string input = Console.ReadLine();
int temperature = int.Parse(input);
if (temperature < 21)
{
Console.WriteLine("Too cold!");
}
else if (temperature == 21)
{
Console.WriteLine("Just right.");
}
else if (temperature == 22)
{
Console.WriteLine("Just right.");
}
else (temperature > 22)
{
Console.WriteLine("Too hot!");
}
2 Answers
Steven Parker
231,269 PointsA plain "else" statement (the last one) does not take a conditional expression. It doesn't need one since it handles any case not already covered by the "if/else if" chain.
else
{
Console.WriteLine("Too hot!");
}
James King
3,670 PointsHey Steve, are you guys available for questions basically 24/7?
Steven Parker
231,269 PointsI'm not sure what you mean by "you guys". I'm another student like yourself, so it's "us guys".
And I may be on frequently, but definitely not "24/7"! But there's a lot of students, and from many countries, so there's a chance of a quick reply from someone at nearly any time.
James King
3,670 PointsJames King
3,670 PointsThank you! I actually figured that out very shortly after I posted this :)