0

Homework question... my code compiles and I can enter the array and exit with a sentinel value, but it's not passing the array correctly to the Statistics method to perform the operations. What am I missing? I just want some hints, not answers.

class IntegerFacts
{
   static void Main()
  {
  int count, min, max, add;
  double avge;


  int[] listOfTen = new int[10]; 
  FillArray(listOfTen);
  Statistics(listOfTen, out count, out max, out min, out  add, out avge);

   WriteLine("The array has {0} values", count);
   WriteLine("The highest value is {0}", max);
   WriteLine("The lowest value is {0}", min);
   WriteLine("The sum of the values is {0}", add);
   WriteLine("The average is {0}", avge);

   }

   public static int[] FillArray(int[] array)
   {

       array = new int[10]; 
       int counter = 0;

      do
   {
       Write("Enter up to 10 numbers of any length, type 999 to stop > ");
          string entryString = ReadLine();
   if (entryString == "999")
   {
       return array;
   }
       else
       {
           array[counter] = Convert.ToInt32(entryString);
           ++counter;
           }
       } while (counter < 10);
       return array;
   }

   public static void Statistics(int[] array, out int els, out int high, out int low, out int sum, out double avg)
   {
       els = array.Count();
       high = array.Max();
       low = array.Min();
       sum = array.Sum();
       avg = array.Average();
   }   

}
Sнаđошƒаӽ
  • 16,753
  • 12
  • 73
  • 90

0 Answers0