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# Basics (Retired) Perfect if / else if / else

hi, why does my code show compilation error?

hi , what is wrong in the code attached?

CodeChallenge.cs
string input = Console.ReadLine();
int temperature = int.Parse(input);
if (temperature < 21 )
{
System.Console.WriteLine("Too cold!");
}
else if (21 =< temperture =< 22)
{
System.Console.WriteLine("Just right.");
}
else (tempertaure > 22 )
{
System.Console.WriteLine("Too hot!");
}

2 Answers

you spelled temperature differently, first you spelled it temperature twice, and then tempertaure twice

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I received your request for assistance :email: In addition to the spelling mistakes listed in Susannah Klanecek 's answer, you also have this line:

else if (21 =< temperture =< 22)

Note that the equals sign must come after the greater than or less than sign. So they need to switch places:

else if (21 >=  temperture <= 22)

Also, an else does not take nor accept a condition. An if takes a condition as well as an else if, but not an else. We use else to say what happens when everything else before it has failed.

I believe you can get it with these hints, but let me know if you're still stuck! :sparkles: