I am attempting to display a random array whilst also displaying the sum of that array yet I can't get it to work, I know how to do it with a for loop but I was instructed on doing a while loop instead, any ideas?
private void SumOfArray() {
myWindow.clearOut();
int total = 0;
int[] a = new int[4];
int i;
i = 0;
while (i < a.length) {
i++;
a[i] = 1 + (int) (Math.random() * 10);
}
i = 0;
while (i < a.length) {
i++;
myWindow.writeOutLine(a[i]);
}
while (i < a.length) {
total += a[i];
i++;
}
myWindow.writeOutLine(total);
}