I was wandering if I could get some help in refining my code for the following problem:
"Write a java program that declares an array alpha of 50 elements of type double. Initialise the array so that the first 25 elements are equal to the square of the index variable and the last 25 elements are equal to 3 times the index variable. Output the array so that the first 10 elements are printed on each line."
my code so far:
import java.math;
void main(String[] args){
double[] alpha = new double(15);
int index = 0;
for(int i=0; i<24; i++){
alpha[i].length = pow(index,2);
}
for(int i=25;i<49;i++)
{
alpha[i].length = pow(index,3);
}
for(int i=0; i<10; i++)
{
System.out.println(alpha[i].length,"\n");
}
}