int totalRainfall = 0, dailyRainfall = 0, maxDailyRainfall = 0, currentDay = 0, rainlessDays = 0, maxRainlessDays = 0;
Declaring many variables in one declaration is generally not the best style. Some code reformaters will try to fill out the line with all the declarations. Documenting each variable is more difficult.
public static final short NUMBER_OF_DAYS = 7;
Using short was nice, altho for single numbers the savings in memory is inconsequential. Shorts are expanded to do any computation. Why didn't you use "byte" type?
int totalRainfall = 0, dailyRainfall = 0, maxDailyRainfall = 0, currentDay = 0, rainlessDays = 0, maxRainlessDays = 0; for( ; currentDay < NUMBER_OF_DAYS ; currentDay++ )
Leaving out the for loop initialization saves an infinitesimal amount of CPU time, but causes big problems for the reader, who has to read the program backwards looking for the assignment to that variable. Easy in this case, but it creates a big interruption in reading speed.
day = 1;
while (day <= 7)
{
totalRainfall += rainfall;
System.out.println("Rainfall for day " +day + " is " +rainfall + " millimeters.");
day++;
rainfall = SavitchIn.readLineInt();
System.out.println("Total rainfall so far is " +totalRainfall);
if (rainfall > maxRainfall)
maxRainfall = rainfall;
}
if (maxRain <= rain)
maxRain = rain;
else
maxRain = maxRain;
}
int averageRainfall = 0;
static final int DAYS = 7;
for (int day=0; day < DAYS; day++) {
String rainStr = JOptionPane.showInputDialog(null, "Enter rainfall");
int rain = Integer.parseInt(rainStr);
averageRainfall = averageRainfall + rain;
}
averageRainfall = averageRainfall / DAYS;
. . .
{
if (rain == 0)
clearDay++;
else