Here’s my try at some basic C# programming. The program is meant to ask the user for a size of an array, then to fill the array, print out the array and finally find the average of the numbers they used to fill the array. The program currently doesn’t compile. This is my first time doing this without any sort of reference book so can someone help explain to me what I’m missing? Thanks. EDIT: All of the program works except the part about finding the average of the numbers in the array. Also, if there are any silly mistakes that aren’t prudent for production-level coding please let me know.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _9_21_Test
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter the amount of numbers you would like to find the average of: ");
int arraylength = Int32.Parse(Console.ReadLine());
int[] AverageArray = new int[arraylength];
//filling the array with user input
for (int i = 0; i < AverageArray.Length; i++)
{
Console.Write("enter the numbers you wish to find the average for: ");
AverageArray[i] = Int32.Parse(Console.ReadLine());
}
//printing out the array
Console.WriteLine("here is your array: ");
for(int i=0; i < AverageArray.Length; i++)
{
Console.WriteLine(AverageArray[i]);
}
Console.WriteLine(FindAverage);
}
}
//Method to find the average is another class for learning porpoises
class Calcs
{
public static double FindAverage(int[] averageNumbers);
int arraySum=0;
for(int i =0; i < averageNumbers.Length; int i++)
arraysum+=arraysum;
return double average = arraysum/averageNumbers.Length;
}
}
Change
to
and
to
If you wish to discuss the concepts, we will be more than willing to help.