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# 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

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!