You have requested to develop a program that will record and

You have requested to develop a program that will record and process the rainfall totals of a 12 month period. You would use an array to store each month\'s total. Once all 12 months amounts are entered then your solution need to process this array to complete the following requirements: The user wants to know the total rainfall for the year. Then you will need to calculate the average monthly rainfall You will then need to find the month with the most rainfall and the month with the least amount of rainfall

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();

       }

          

      

   }

}

 You have requested to develop a program that will record and process the rainfall totals of a 12 month period. You would use an array to store each month\'s to
 You have requested to develop a program that will record and process the rainfall totals of a 12 month period. You would use an array to store each month\'s to
 You have requested to develop a program that will record and process the rainfall totals of a 12 month period. You would use an array to store each month\'s to

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site