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

C# Const - Constant Variable Code Declaration

In trying to set constant variables to get rid of "Magic Number" I wrote the following code. I removed the "private" designator originally like the original constant revenue but go the same response when I asked it to check my work. This should have been simple, I thought, so must be missing something.

The response I keep getting from the Checker is "BUMMER - Did you set a constant variable for 100000?" ?!

Also, I'm checking the box to include my code. Last time it didn't include my code?!

CodeChallenge.cs
const int revenue = 125000;
private const int  _lowRevenue = 100000;
private const int _medRevenue = 150000;
private const string _lowIndicator = "red";
private const string _medIndicator = "yellow";
private const string _goodIndicator = "green";

string status = null;

if (revenue < _lowRevenue)
{
    status = _lowIndicator;
}
else if (revenue < _medRevenue)
{
    status = _medIndicator;
}
else
{
    status = _goodIndicator;
}

1 Answer

Steven Parker
Steven Parker
229,732 Points

You're not defining class components here, so you don't need the "private" access modifiers.

Also, the challenge doesn't seem to like the extra space between "int" and "_lowRevenue".