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.

Jordan Lassiter
Courses Plus Student 347 PointsCode is not validating the <=0 if statemenet
When I run my code with the
if(minutes <= 0)
{
Console.WriteLine(minutes + " is not an acceptable value.");
continue;
}
the program still seems to jump to the else if statement "Better then nothing"
here is the full code thank you in advance for the help
using System;
namespace Fitness.AP
{
class Program
{
static void Main()
{
int runningTotal = 0;
bool keepGoing = true;
while(keepGoing) {
// Prompt user for minutes exercised
Console.Write("Enter how many minutes you exercised or type \"quit\" to exit:" +" ");
// gathering input from user
string workoutmin = System.Console.ReadLine();
if(workoutmin == "quit")
{
keepGoing = false;
}
else
{
int minutes = int.Parse(workoutmin);
if(minutes <= 0)
{
Console.WriteLine(minutes + " is not an acceptable value.");
continue;
}
else if(minutes <= 10)
{
Console.WriteLine("Better than nothing, am I right?");
}
else if(minutes <= 30)
{
Console.WriteLine("Way to go hot stuff!");
}
else if(minutes <= 60)
{
Console.WriteLine("You must be a ninja warrior in training!");
}
else
{
Console.WriteLine("Okay, now you're just showing off!");
}
runningTotal= runningTotal + minutes;
//writing user input back to them
Console.Write("You have entered:" + " " + runningTotal + " " + "Minutes" + "\r\n " );
}
}
Console.WriteLine("Bye");
}
}
}

Robert Anthony
19,952 PointsWhat exactly did you type in as the input?
2 Answers

Steven Parker
220,415 PointsThis program seems to build and run without errors.
You will see the "Better than nothing, am I right?" message when you enter a number between 1 and 10 (inclusive).

Erik Gabor
6,427 PointsI think the problem is that you run and older .exe and you did not compile the current modifications. I've tested the program for negative and 0 values and it does not go to "Better than nothing"
Steven Parker
220,415 PointsSteven Parker
220,415 PointsTo allow a full analysis of the issue, make a snapshot of your workspace and post the link to it here.