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# Objects Loops and Final Touches Constants

Am I missing something?

I believe I have done everything right as I was ased and yet it still doesnt recognize my answers as correct. Have I done anything wrong? If so please point towards whatever I have done wrong because I simply do not understand what am I supposed to do here.

CodeChallenge.cs
const int revenue = 125000;
string status = null;

if (revenue < 100000)
{
    status = "red";
}
else if (revenue < 150000)
{
    status = "yellow";
}
else
{
    status = "green";
}

1 Answer

Tim Danner
Tim Danner
3,281 Points

I remember doing this challenge too, had to declare variables for each number and string to replace the magic numbers and magic strings.

const int high = 150000;
const int low = 100000;

const string upperClass = "green";
const string middleClass = "yellow";
const string lowerClass = "red";

Please enlighten me if you have better ideas of naming the variables, and I hope this helps. 😀

Ive tried applying this code but either it doesnt work or I dont know in what order to place it

Edi: I figured it out. Thank you very much!