Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ewa Sidor
1,084 PointsCould you check my work and tell me what is wrong with my code?
I do not understand whats the error message. It doesn't make any sens to me.
string input = System.Console.ReadLine();
int temperature = int.Parse(input);
if(temperature<21)
{
System.Console.WriteLine("Too cold!");
}
else if(temperature<=22)
{
System.Console.WriteLine("Just right.");
}
else(temperature>22)
{
System.Console.WriteLine("Too hot!");
}
```Error :
StudentsCode.cs(19,4): error CS1525: Unexpected symbol `{'
StudentsCode.cs(19,5): warning CS0642: Possible mistaken empty statement
Compilation failed: 1 error(s), 1 warnings

Ewa Sidor
1,084 PointsStudentsCode.cs(19,4): error CS1525: Unexpected symbol `{' StudentsCode.cs(19,5): warning CS0642: Possible mistaken empty statement Compilation failed: 1 error(s), 1 warnings
2 Answers

andren
28,521 PointsThe problem is that else
statements does not accept conditions. An else
statement is automatically executed if the statements above it are not run. In this case you can simply remove the condition and your code will work fine since the previous statements cover temperatures equal to and below 22. Like this:
string input = System.Console.ReadLine();
int temperature = int.Parse(input);
if(temperature<21)
{
System.Console.WriteLine("Too cold!");
}
else if(temperature<=22)
{
System.Console.WriteLine("Just right.");
}
else
{
System.Console.WriteLine("Too hot!");
}

Ewa Sidor
1,084 PointsThank you. It works now :)
Kyle Southerland
UX Design Techdegree Student 11,117 PointsKyle Southerland
UX Design Techdegree Student 11,117 PointsWhat's the actual error message you are receiving?