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 trialSammy Lebisch
3,743 PointsIt says my error is can't convert void to int, but I didn't use void anywhere. What did I do wrong?
pls help
string input = Console.ReadLine();
int temperature = int.Parse(input);
int temp = Console.WriteLine("Enter Temp.");
if (temp < 21){
Console.Write("Too cold!");
}
else if (temp <= 22){
Console.Write("Just right.");
}
else if(temp > 22){
Console.Write("Too hot!");
}
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey Sammy,
You are definitely on the right track, and you have all the correct syntax, but there are just a couple of small things.
The instructions never asked for you to include a Console.WriteLine()
or to create a new variable temp
. So, that whole line needs to be deleted.
Next, the pre-loaded code includes a variable that will have the value that is passed in. It is the temperature
variable, and this is the variable that needs to be checked against in your if
and else if
statements.
I've included the updated code, as you do have all the syntax correct for you to review. It's good to also remember that challenges and the instructions are very specific, and the code checker is very picky. Everything needs to be exactly as the instructions ask or you end up with the Bummer!
.
string input = Console.ReadLine();
int temperature = int.Parse(input);
if (temperature < 21){
Console.Write("Too cold!");
}
else if (temperature <= 22){
Console.Write("Just right.");
}
else if(temperature > 22){
Console.Write("Too hot!");
}
Nice job and Keep Coding! :)
Sammy Lebisch
3,743 PointsSammy Lebisch
3,743 PointsThanks you very much for your time and help good sir!