You have requested to develop a program that will record and
Solution
Please find the solution below:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class RainfallProcessor {
public static void main(String[] args) {
String [] months = {\"January\", \"February\", \"March\", \"April\",
\"May\", \"June\", \"July\", \"August\",
\"September\", \"October\", \"November\", \"December\"};
double [] rainfall = new double [12];
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
try {
for(int count = 0; count < 12; count++){
System.out.println(\"Enter \"+months[count]+\" Rainfall Data: \");
double d = Double.parseDouble(bufferedReader.readLine());
rainfall[count] = d;
}
double totalRainfall = 0;
double maximumRainfall = 0;
int maxRainMonth = 0;
double minimumRainfall = rainfall[0];
int minRainMonth = 0;
for(int count = 0; count < 12; count++){
totalRainfall += rainfall[count];
double monthRainfall = rainfall[count];
if(maximumRainfall < monthRainfall){
maximumRainfall = monthRainfall;
maxRainMonth = count;
}
if(minimumRainfall > monthRainfall){
minimumRainfall = monthRainfall;
minRainMonth = count;
}
}
System.out.println(\"Total Rainfall: \"+totalRainfall);
System.out.println(\"Average Rainfall: \"+ (totalRainfall/12) );
System.out.println(\"Least Rainfall: \"+minimumRainfall+\" in month of \"+months[minRainMonth]);
System.out.println(\"Most Rainfall: \"+maximumRainfall+\" in month of \"+months[maxRainMonth]);
} catch (NumberFormatException e) {
System.out.println(\"Please Enter Numeric Data and Retry...\");
} catch (IOException e) {
e.printStackTrace();
}
}
}


