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
Henrik Christensen
Python Web Development Techdegree Student 38,297 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.