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#

Error CS0103 : The name minutes does not exist in the current context : Could someone please help with this error

I cannot seem to find how to fix this error could someone please help me thank you

using System; namespace Treehouse.fitnessFrog { 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 ");
            string entry = Console.ReadLine();
            if(entry == "quit")
            {
              keepGoing = false;

            }else{

              try
              {
                int minutes = int.Parse(entry);

                if(minutes <- 0)
              {
                Console.WriteLine("Not Acceptable");
                continue;
              }
              else if(minutes <= 10)// Number 1 
              {
                Console.WriteLine("Better than nothing, am I right ?");
              }
              else if(minutes <= 30) // Number 2
              {
                Console.WriteLine("Your still a shit cunt ngl ");
              }
              else if(minutes <= 60) // Number 3 
              {
                Console.WriteLine("Your doing all right i guess");
              }
              else 
              {
                Console.WriteLine("Cool story bro");
              }
              }
              catch(FormatException)
              {
                  Console.WriteLine("That is not valid");
                  continue;
              }                   
            // Add minutes exercised to total 
            runningTotal = runningTotal + minutes;

            // Display total minutes exercised to the screen 
            Console.WriteLine("You've entered "+ runningTotal + " minutes");

            // Repeat until user quits  
        }


      }
        Console.WriteLine("Goodbye mate"); 
  }

} } //These are meant to be in the code but it doesn't show it , but please still count this is

2 Answers

Damien Watson
Damien Watson
27,419 Points

Hi Keanu,

When checking if minutes is lessthan/equal to 0, you used a minus instead of equals. I don't know if this is it, but it is an error.

if(minutes <- 0)

// should be 

if(minutes <= 0)

Thanks Damien it was a error in my code , but it wasn't the one stopping my code but thanks heaps for pointing it out, i have to analyse my code harder for small mistakes like that haha

Damien Watson
Damien Watson
27,419 Points

Ah, sorry I had a brain fade this morning. Was it because you have initialised the variable minutes inside the 'try' statement which makes it a local variable?

Its no problem , i moved it just underneath the entry variable

but it still comes up with the same error ?