So I have searched for different methods, and they all seem WAY to complicated. So exactly what do I need to do, I would prefer not use the array util, in order to print the array? So far I have this:
public static void main(String[] args)
{
int a[] = {2, 3, 5, 7, 11, 13};
int sum = 0;
System.out.printf("The average of \n" + a );
for(int i = 0; i < a.length; i++)
sum = sum + a[i];
double avg = sum / a.length;
System.out.println("\nis\n " + avg);
}
And it prints this:
The average of
[I@1bd0dd4
is
6.0
Which I am assuming (not sure I am correct) means that it is printing the location of the array not what is contained. (Please do correct me if I am wrong) As well, we were given the answer which is 6.83 and mine is reading out at 6.0 which means I am doing something wrong. Any ideas as to what how to print the array without using any special libraries and where the math issue is coming from?