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. 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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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. 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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Passing Array as Argument
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education