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
STAFF
Jennifer Nordell
Treehouse Staff

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