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

Aly Khedr
Aly Khedr
470 Points

Any Idea what's wrong?

Supposed to make a program that will send certain comments for certain numbers

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

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

2 Answers

Steven Parker
Steven Parker
229,732 Points

:mailbox_with_mail: Hi, I got your request.

It looks like you just forgot to close that last code block after the "else". Just add the missing brace at the end and you should have it. Otherwise, good job! :+1:

Antonio De Rose
Antonio De Rose
20,884 Points

missing the last curly brace

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

if(temperature <= 20)
{
    Console.WriteLine("Too Cold!");
}
else if(temperature <= 22)
{
    Console.WriteLine("Just right.");
}
else
{
    Console.WriteLine("Too hot!");
}// you are missing this curly brace