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

Replace the magic numbers and strings in the if / else if / else statement with constants.

whats wrong in this? it says did you change if/else if/else error

CodeChallenge.cs
const int revenue = 125000;
string status = null;
const string r="red";
const string y="yellow";
const string g="green";
const int num1=100000;
const int num2=150000;
if (revenue < num1 )
{
    status = r;
}
else if (revenue <num2 )
{
    status = y;
}
else
{
    status = g;
}

1 Answer

Steven Parker
Steven Parker
231,236 Points

You're going to love this one.

I removed the spaces between the constant names and the closing parentheses of the expressions and it passed. :stuck_out_tongue_winking_eye:

You may want to report this as a bug to Support.

wow! it worked so funny!

Demar Jones
Demar Jones
10,583 Points

thank you!! Steven this was driving me crazy!