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

The preview said I have an error in line 0. It said line 0 has unexpected symbol '{'. But there is no line 0

I couldn't find any problem..... Sorry please help me. And I wanna know about the warning. If I want to make this code form perfectly, I mean without warning, what should I do more?

CodeChallenge.cs
    string input = Console.ReadLine();
int temperature = int.Parse(input);

if(temperature < 21)
{
    Console.WriteLine("Too cold!");
}
    else if(temperature <= 22)
    {
 Console.WriteLine("Just right");
    }
else(temperature > 22)
{
    Console.WriteLine("Too hot!");
}

1 Answer

I'm not sure how it's calculating line numbers, but your error is in the else statement. else statements don't have conditions. so it should be

else
{
    Console.WriteLine("Too hot!");
}```

you'll also need to add a period on the end of "just right" as the example has one.  it's really strict.