[SOLVED] Multidimensional array

I am trying to make a multidimensional array that saves temperatures in an month by day and hour. What I need is a method that put all the temperatures together and outputs and mean temperature for the whole month.. What I got now is a method that adds all temps together, put how can I make it so that it divides this number on all the hours in the hour??

Here is code:

Code:

`// Overall temp, all put together:`

public double finnGjesnittTotal(){

double sum = 0;

for (int dag = 0;dag <temp.length; dag++){

for (int time = 0; time < temp[dag].length; time++){

sum += temp[dag][time];

}

}

return sum;

}

This outputs all the temperature together.. But I need a method that divides this on all the temperatuers.

I tried to divide this on this:

sum = sum / (lenth[time].length * length[dag].length);

Does not work..

Dag = day

Time = hour

Any clues.

Ok, tried to follow your example..

Code:

`// Gjennomsnittet totalt:`

public double finnGjesnittTotal(){

double sum = 0;

for (int dag = 0; dag <temp.length; dag++){

int counter = 0;

for (int time = 0; time < temp[dag].length; time++){

sum += (temp[dag][time]);

counter++;

sum = sum / (double) counter;

}

}

return sum;

}

Seems to be some sort of mistake somewhere.. Thanks for them answers anyway...