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# 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