Java Help

Status
Not open for further replies.

happyhippie

Seniorius Lurkius
8
Thanks for the willingess to help.

What I'm trying to do is to condense an array [8760] that contains the *hourly temparature of a year into another array that contains the average *daily temperatures of a year. So basically take average of the numbers from 0 to 23 and put them in [0] of the new array then take the average of 24 to 47 and put them in [1] of the new array. A friend commented that this could be done with for loops, but he wasn't sure of how exactly.

I don't have any code yet, but I hope that helps you help me. Again, thanks a lot.

~Happy
 

0

Ars Scholae Palatinae
609
Forgive me if this isn't the most elegant solution or if there are any syntax errors--I whipped this out as I should have been leaving for work.

code:<HR>
Code:
int array2pos = 0;
array2[array2pos] = 0.0;<P>for ( int cnt = 0; cnt < 8760; cnt++ )
{
    if ( 0 == ( cnt % 24 ) && 0 != cnt )
    {
        array2[array2pos] /= 24.0;
        array2pos++;
        array2[array2pos] = 0.0;
    }
    
    array2[array2pos] += array1[cnt];
}  <P>array2[array2pos] /= 24.0;

Hope this helps.
 
Status
Not open for further replies.