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.

C# C# Basics (Retired) Perform if / else

Rasmus Hall
Rasmus Hall
1,260 Points

CS1525

using System;
namespace Nanomech
{
  class Program
  {
      static void Main()
      {
        int runningTotal;
        runningTotal = 0;
        bool keepGoing = true;

          while(keepGoing)
          {
                      Console.Write("Skriv hvor mange minutter du har motioneret siden sidst eller skriv ud for at lukke programmet: ");

            string entry = Console.ReadLine();

            if(entry == "ud")
            {

              keepGoing = false;

            }
            else 
            {

              Console.WriteLine("Du har motioneret i " + entry + " minutter!");

              int minutes = int.Parse(entry);
              runningtTotal = runningTotal + minutes;

            }
          }



      }
  }
}

and yet it says

Program.cs(30,15) : error CS 0103: the name 'runningTotal' does not exist in the current context

Moderator edited: Markdown added so that code renders properly in the forums.

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I think you're probably doing great, but you've made a typo. Take a look at this line:

runningtTotal = runningTotal + minutes;

That should be:

runningTotal = runningTotal + minutes;

In your version you have runningtTotal instead of runningTotal. Note the extra lower case "t" in your version immediately before the capital "T".

Hope this helps! :sparkles:

Rasmus Hall
Rasmus Hall
1,260 Points

wow jennifer nordell saves the day 2 times in 1 day :D

thankyou so much, have not been able to continue so have just been refreshing the notifications window