My code compiles and runs, but it doesn't execute as many times as I need it to. I need it to ask for input 12 times (for each month). What am I missing? Here's the code:
[/highlight = Java]
import java.util.Scanner;
public class HighestTemp {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the temperature for the month:");
double highestValue = in.nextDouble();
int highestMonth = 1;
for (int currentMonth = 2; currentMonth <= 12; currentMonth++) {
double nextValue = in.nextDouble();
if (nextValue > highestValue) {
highestValue = nextValue;
highestMonth = currentMonth;
}
System.out.println("The highest value is: " + highestValue +
" and the month of the highest value is: " + highestMonth);
}
}
}
[/highlight]
Thanks for any help!!!