JAVA PROGRAM Lab #1 Enhancements:1. For the maximum and minimum rainfall amount, also display the month where that happened. For example:a. Maximum rainfall: January, 88.2 inchesb. Minimum rainfall: July, 12.3 inches2. Format all numbers with 1 decimal pointsMain class name: RainFall2 (no package name) HERE IS A WORKING CODE, PLEASE MODIFY THIS CODE SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL THE TEST CASSES. IT HAS TO PASS ALL THE TEST CASSES BECAUSE RIGHT KNOW IT DOES NOT PASS THE TEST CASES. THANK YOU import java.util.*; public class Main {     public static void main(String[] args) {         String maxRainfallMonth = "",minRainfallMonth = "";         double maxRainfall,minRainfall,rainFall,avg,tot=0;         Scanner sc = new Scanner(System.in);         System.out.println("Enter the rainfall for month 1: ");         double rainfall = sc.nextDouble();         maxRainfall = rainfall;         minRainfall = rainfall;         tot = rainfall;         String[] months = {"January","February","March","April",             "May","June","July","August","September","October",             "November","Decemeber",};         maxRainfallMonth = months[0];         minRainfallMonth = months[0];        for(int i=1; irainfall){             minRainfall = rainfall;             minRainfallMonth = months[i];         }         if(maxRainfall

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter1: Creating Java Programs
Section: Chapter Questions
Problem 12PE
icon
Related questions
Question

JAVA PROGRAM

Lab #1 Enhancements:1. For the maximum and minimum rainfall amount, also display the month where that happened. For example:a. Maximum rainfall: January, 88.2 inchesb. Minimum rainfall: July, 12.3 inches2. Format all numbers with 1 decimal pointsMain class name: RainFall2 (no package name)

HERE IS A WORKING CODE, PLEASE MODIFY THIS CODE SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL THE TEST CASSES. IT HAS TO PASS ALL THE TEST CASSES BECAUSE RIGHT KNOW IT DOES NOT PASS THE TEST CASES. THANK YOU

import java.util.*;
public class Main
{
    public static void main(String[] args) {
        String maxRainfallMonth = "",minRainfallMonth = "";
        double maxRainfall,minRainfall,rainFall,avg,tot=0;
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter the rainfall for month 1: ");
        double rainfall = sc.nextDouble();
        maxRainfall = rainfall;
        minRainfall = rainfall;
        tot = rainfall;
        String[] months = {"January","February","March","April",
            "May","June","July","August","September","October",
            "November","Decemeber",};
        maxRainfallMonth = months[0];
        minRainfallMonth = months[0];
       for(int i=1; i<months.length; i++){
       System.out.println("Enter the rainfall for month "+(i+1)+": ");
        rainfall = sc.nextDouble();
        if(minRainfall>rainfall){
            minRainfall = rainfall;
            minRainfallMonth = months[i];
        }
        if(maxRainfall<rainfall){
            maxRainfall = rainfall;
            maxRainfallMonth = months[i];
        }
        tot += rainfall;
       }
    avg = tot/12;
    System.out.printf("Maximum rainfall: %s, %.1f inches\n",maxRainfallMonth,maxRainfall);
    System.out.printf("Minimum rainfall: %s, %.1f inches\n",minRainfallMonth,minRainfall);
    System.out.printf("Total rainfall:%.1f inches\n",tot);
    System.out.printf("Average rainfall:%.1f inches\n",avg);
    }
}

 

Test Case 1

 
 
Enter the rainfall amount for month 1:\n
1.2ENTER
Enter the rainfall amount for month 2:\n
2.3ENTER
Enter the rainfall amount for month 3:\n
3.4ENTER
Enter the rainfall amount for month 4:\n
5.1ENTER
Enter the rainfall amount for month 5:\n
1.7ENTER
Enter the rainfall amount for month 6:\n
6.5ENTER
Enter the rainfall amount for month 7:\n
2.5ENTER
Enter the rainfall amount for month 8:\n
3.3ENTER
Enter the rainfall amount for month 9:\n
1.1ENTER
Enter the rainfall amount for month 10:\n
5.5ENTER
Enter the rainfall amount for month 11:\n
6.6ENTER
Enter the rainfall amount for month 12:\n
6.0ENTER
Maximum rainfall: November, 6.6 inches\n
Minimum rainfall: September, 1.1 inches\n
Total rainfall: 45.2 inches\n
Average rainfall: 3.8 inches\n
 

Test Case 2

 
 
Enter the rainfall amount for month 1:\n
1.29ENTER
Enter the rainfall amount for month 2:\n
6.68ENTER
Enter the rainfall amount for month 3:\n
2.37ENTER
Enter the rainfall amount for month 4:\n
3.46ENTER
Enter the rainfall amount for month 5:\n
5.15ENTER
Enter the rainfall amount for month 6:\n
1.74ENTER
Enter the rainfall amount for month 7:\n
6.53ENTER
Enter the rainfall amount for month 8:\n
2.52ENTER
Enter the rainfall amount for month 9:\n
3.31ENTER
Enter the rainfall amount for month 10:\n
1.17ENTER
Enter the rainfall amount for month 11:\n
5.53ENTER
Enter the rainfall amount for month 12:\n
6.01ENTER
Maximum rainfall: February, 6.7 inches\n
Minimum rainfall: October, 1.2 inches\n
Total rainfall: 45.8 inches\n
Average rainfall: 3.8 inches\n
 
 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT