Question: Write a RainFall class that has the following field: an array of doubles that stores the rainfall for each of the 12 months of the

Write a RainFall class that has the following field: an array of doubles that stores the rainfall for each of the 12 months of the year (where the first index corresponds with January, the second with February, etc.) The class should also have the following methods: a method that returns the total rainfall for the entire year a method that returns the average monthly rainfall for the year a method that returns the month with the most rain as a string a method that returns the month with the least rain as a string Demonstrate the class in a program that takes 12 doubles from the user (take the doubles in the order of the months of the year, the first corresponding to the rainfall in January, etc.). Do input validation: if the user inputs a negative number, ignore it and continue asking them for input until you have 12 nonnegative doubles. Once the user has given you all 12 doubles, create an instance of the RainFall class and call its methods, printing out the total rainfall, the average monthly rainfall, the month with the most rain, and the month with the least rain, each on a separate line.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!