Hey I am working on a school project and I need help with 3 errors I keep getting when I compile.
I have this array storing my strings.
and I need the program to Return the Month that rainfall is the greatest.Code:private String[] months = {"January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
Here is the errors I am receiving.Code:public double getHighestMonth(){ double highest = values[0]; String month = months[0]; for (int index = 1; index < values.length; index++){ if (values[index] > highest) highest = values[index]; month = months[index]; } return month; }
Any help would be greatly appreciated.Code:RainFall.java:35: incompatible types found : java.lang.String required: double return month; ^ RainFall.java:40: incompatible types found : java.lang.String required: double double month = months[0]; ^ RainFall.java:45: incompatible types found : java.lang.String required: double month = months[index]; ^ 3 errors![]()




Reply With Quote