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 trialNipi Tiri
2,988 PointsWhat Im doing wrong?
I dont get it
2 Answers
Steven Parker
231,210 PointsWithout seeing your solution, I would point out that this challenge is looking for three possible outcomes. You could test for each condition separately, like this:
if (value < MINIMUM) { ... } // too low
if (value >= MINIMUM && value <= MAXIMUM) { ... } // in between
if (value > MAXIMUM) { ... } // too high
or, you could check just two conditions and rely on else to handle the third, like this:
if (value < MINIMUM) { ... } // too low
else if (value > MAXIMUM) { ... } // too high
else { ... } // in between
Either method works, but the latter is a bit more efficient.
micram1001
33,833 PointsYou need to write the if / else if / else statements to match the tables in the challenge.
string input = Console.ReadLine();
int temperature = int.Parse(input);
if (temperature < 21)
{
Console.WriteLine("Too cold!");
}
else if (temperature > 22)
{
Console.WriteLine("Too hot!");
}
else
{
Console.WriteLine("Just right.");
}
bothxp
16,510 Pointsbothxp
16,510 PointsCan you post you code so that we can take a look at what you are writing.