I am trying to write a method that will return the month with the lowest rainfall amount. The problem is that I have to initialize my variable but then my method always returns a "0". How can I fix this problem?
Here is my code:
public int getLowestRainFallMonth()
{
double lowest = rainAmount[0];
int lowMonth = 0;
for (int index = 1; index < ARRAY_SIZE; index++)
{
if (rainAmount[index] < lowest)
{
lowest = rainAmount[index];
lowMonth = index;
}
}
return lowMonth;