i cant seem to figure out the logic, here's my code
class stringrays {
public static void main (String[] args) {
int[] numrays = {23, 6, 47, 35, 2, 14};
int i;
int z;
int y;
for (i=1; i < numrays.length; i++) {
z = numrays[0] + numrays[i];
System.out.println(z);
}
}
the above results shows 29 70 58 25 37
which means that array 0 adds array 1, then array 0 adds array array 2 and so on.
what i want, is to add the first array 0 onto the next array and so on.. using a loop condition.
then get the average of the sum.
int z = numrays[0]; /* in loop*/ z += numrays[i];?