I'm studying for finals so I've been having problems with this assignment and I'm just not understanding what I'm doing wrong, I was hoping some user here could help me out. I have to write an array that will computer average using a .Length property to find out how many elements are in my array, with a for(;;) loop. This is my code so far, and it works without the numbers I need to use.
static double ComputeSum(int [] intArray)
{
int intsum = 0;
int intCounter;
for (intCounter=0; intCounter<intArray.Length; intCounter++)
{
intsum += intArray[intCounter];
}
return intsum;
}
static double ComputeAverage(int [] intArray)
{
return (double)ComputeSum(intArray) / intArray.Length;
}
the numbers I have to use though are all doubles, and I'm not sure how to fix this.
here are the numbers
int[] numbers = new int[9.7, 2.2, 4.3, 1.7, 5.6, 3.6, 4.5, 1.3, 4.6, 3.0];
if this is too vague I can answer questions, and I appreciate any help I can get.