for (int i = 0; i < 15; i+=3) {
System.out.print("Enter Exam Mark:");
Marks[i] = input.nextInt();
System.out.print("Enter Coursework Mark:");
Marks[i+1] = input.nextInt();
System.out.print("Enter Weighting:");
Marks[i+2] = input.nextInt();
}
public double[] computemarks(int[] Marks) {
double[] marks = new double[6];
double computedmark;
for (int x = 0; x < 15; x+=3) {
if (Marks[x] >= 35 && Marks[x+1] >= 35) {
computedmark = ((Marks[x+1] * Marks[x+2]) + (Marks[x] * (100.0 - Marks[x+2]))) / 100.0;
} else {
computedmark = Math.min(Marks[x], Marks[x+1]);
}
marks[x] = computedmark;
}
return marks;
}
Why is "ArrayIndexOutOfBoundsException" showing during runtime? I've played around with the for loops but it's still not working.
FYI, The Marks array has 18 available slots in memory.