Here's what I have so far
double[] num = {1.9, 2.9, 3.4, 3.5};
double max = num [0];
for (int i = 1 ; i < num.length ; i++)
{
if (num [i] > max)
max = num [i];
}
System.out.println ("Max is " + max);
I need to find the index of the greatest value. I've tried printing the index by putting a sentence inside the if statement, and I've also tried by storing i into another variable. None of them worked.
numand[i]? Perhaps that is causing it. Are you getting compilation errors or what?, and then in the loop instead ofmax = num[i]`, set the idx to to num[i]?max = num[0];takes care of that.