Greetings,
I am attempting to compile the code below, but I am receiving an error
message when I do so. The error message is: "CSO161:
'Forloop.CalcAvg(int)': Not all code paths return a value". Any idea as
to what I'm doing wrong? I'm sure it's something simple.
Thanks in advance!
public class ForLoop
{
public static void Main()
{
String strNumber;
int number;
double result;
Console.Out.WriteLine("Please enter in a number:");
strNumber = Console.ReadLine();
number = Convert.ToInt32(strNumber);
result = calcAve(number);
}
public static double calcAve(int number)
{
String strValue;
int total, value, count;
double ave;
total = 0;
for(count = 0; count < number; count ++)
{
Console.Out.Write("Enter a value: ");
strValue = Console.ReadLine();
value = Convert.ToInt32(strValue);
total = total + value;
ave = (double)total / count;
return ave;
}
}
}
*** Sent via Developersdex http://www.developersdex.com ***