Q:

Please help me understand Arrays

I am in my 4th week of programming and my teacher is moving VERY quickly. I am so confused. I very vaguely understand arrays as is. My teacher wants us to create an array (a double) that has 50 elements, I need to loop through that array and have the first 25 have an if statement set to the index squared, the else 3x the index. I need to print that out 10 per line. This is so way over my head and of course my teacher is not going to be available Saturday or Sunday (it is due Sunday). After I got clarification on what the teacher wanted it was Wednesday. I have been going crazy trying to figure out how to do this. I am not asking for an answer, just good solid direction.
Correspondence email from teacher while I was asking for clarification."You’re on the right track but not quite there. The index variable isn’t a set number; it is a reference to a value in the array.  So in the statement:
array[count] = 5; 
count is the index variable and that is the value we are basing our calculations on.  Since it changes, our output would be more like:

0 1 4 9 16 25 36 49 64 81
100 121 .. .. .. .. .. .. .. ..
.. .. .. .. .. 75 78 81 84 87
.. .. .. .. .. .. .. .. .. ..  
.. .. .. .. .. .. .. .. .. ..

Notice also that they should be a full 10 to a line making line 3 have 5 from each of the calculations together."

A:

first part
double[] arr=new double[50];
for(int i=0;i<25;i++)
    arr[i]=i*i;

second part
for(int i=25;i<arr.length;i++)
   arr[i]=3*i;

third part
for(int i=0;i<arr.length;i++)
{

         if((i%10==0)&&i!=0)
             System.out.println(arr[i]+" ");
           else
             System.out.print(arr[i]+" ");

}

I'm not sure if i understood you but the first part is the squared index, the second is the double index, the third is printing the array, notice that after every 10 printings it goes to a new line.

