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.

C# C# Basics (Retired) Perfect if / else if / else

Angus Eliott
Angus Eliott
3,793 Points

if else problem

Hey, could someone help me with this, please ?

string input = Console.ReadLine();
int temperature = int.Parse(input);
if(temperature =< 21) {
    System.Console.Writeline("Too Cold!");
else if (temperature => 21 == > 22){
    System.Console.WriteLine("Just right.");
else if (temperature => 22){
    System.Console.WriteLine("Too hot!");

1 Answer

Ben Reynolds
Ben Reynolds
35,170 Points
  1. The expression "greater/less than or equal to" has the angle bracket before the equals sign (watch out for =< vs <=)
  2. The WriteLine method needs to be written with a capital W and L.
  3. The "else if" condition should read like this: "temperature is greater than or equal to 21 AND temperature is less than or equal to 22."
  4. The second "else if" block can simply be an "else" block without a condition or parentheses. This block will just catch everything else that isn't caught by the "if" or "else if" conditions.