Quote (kyle_lowry2 @ Oct 21 2015 07:29pm)
Scanner keyboard = new Scanner(System.in);
double[] score = new double[5];
int x;
double max;
System.out.println("Enter " + score.length + " scores: ");
score[0]=keyboard.nextDouble();
max = score[0];
for (x=1;x<score.length;x++)
{
score[x]=keyboard.nextDouble();
if(score[x]>max)
max=score[x];
}
System.out.println("highest score is " + score[x]);
}
}
literally can't figure out why
iterate through that loop on paper
x = 1....< score.length(5)? true -> NEXT
x = 2....< score.length(5)? true -> NEXT
x = 3....< score.length(5)? true -> NEXT
x = 4....< score.length(5)? true -> NEXT
x = 5....< score.length(5)? FALSE -> EXIT LOOP
x is now 5
do you see now?
edit: slow to the trigger as usual
This post was edited by Eep on Oct 21 2015 06:41pm