Create a console-based application whose Main() method declares an array of eight integers.
Call a method to interactivelyfill the array with any number of values up to eight.
Call a second method that accepts out parameters for the arithmetic average and the sum of the values in the array.
Display the array values, the number of entered elements, and their average and sum in the Main() method.
I CAN'T DISPLAY THE SUM AND THE AVERAGE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArrayManagement
{
class Program
{
static double arrayMath(double[] myArray, out double sum, out double avg)
{
sum = myArray.Sum();
avg = myArray.Average();
Console.WriteLine("sum is: ",sum);
return sum;
}
static void displayArray(double[] myArray)
{
Console.Write("Your numbers are: ");
for (int i = 0; i < 8; i++)
Console.Write(myArray[i] + " ");
Console.WriteLine();
}
static double[] fillArray()
{
double[] myArray;
myArray = new double[8];
int count = 0;
do
{
Console.Write("Please enter a number to add to the array or \"x\" to stop: ");
string consoleInput = Console.ReadLine();
if (consoleInput == "x")
{
return myArray;
}
else
{
myArray[count] = Convert.ToInt32(consoleInput);
++count;
}
} while (count < 8);
return myArray;
}
static void Main(string[] args)
{
double[] myArray;
myArray = new double[8];
myArray = fillArray();
double sum, avg;
displayArray(myArray);
arrayMath(myArray, out sum, out avg);
}
}
}