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 trialCarmine Bastevole
342 PointsNumberEntry 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
Python Web Development Techdegree Student 38,322 PointsYou have a typo in this line avregeTotal = avregeTotal / NumerEntry; - you wrote NumerEntry instead of NumberEntry - notice the missing b in your line
Carmine Bastevole
342 Pointsa simple Syntax error NumberEntry and not NumerEntry.
Carmine Bastevole
342 PointsCarmine Bastevole
342 PointsJust noticed thank for answering. Sorry for asking.