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) Perfect Wrap Up

Carmine Bastevole
Carmine Bastevole
342 Points

NumberEntry does not exist in the current context

Compiling error. I don't know why it says that message I have initialize the variable. why I cannot use it.

double avregeTotal = 0.0;
          int NumberEntry = 0;

          //Promt the user for numbers.
          while(true)
            {
            NumberEntry++;

            Console.Write("Enter a number or type \"done\" to see the average:");
                var entry = Console.ReadLine();

            if(entry.ToLower() == "done")
                {
                    break;
                }

            try
              {
                  //Add All of the numbers together.
                  avregeTotal += double.Parse(entry);            
              }
            catch(FormatException)
                {
                    Console.WriteLine("That is not valid input.");
                    continue;
                }
            }

          avregeTotal =  avregeTotal / NumerEntry;
           // print the average of all of the numbers by dividing the total by the number of numbers entered.

          Console.WriteLine("The avrege is :" + avregeTotal);

2 Answers

Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

You have a typo in this line avregeTotal = avregeTotal / NumerEntry; - you wrote NumerEntry instead of NumberEntry - notice the missing b in your line

Carmine Bastevole
Carmine Bastevole
342 Points

Just noticed thank for answering. Sorry for asking.

Carmine Bastevole
Carmine Bastevole
342 Points

a simple Syntax error NumberEntry and not NumerEntry.