Demonstrate the class in a program that takes 12 doubles


RainFall class that has the following field:

  • anarrayofdoublesthatstoresthe 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:

  • amethodthat returns the total rainfall for the entire year
  • amethodthat returns the average monthly rainfall for the year
  • amethodthat returns the month with the most rain as astring
  • amethodthat returns the month with the least rain as astring

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

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Demonstrate the class in a program that takes 12 doubles
Reference No:- TGS02850653

Now Priced at $15 (50% Discount)

Recommended (91%)

Rated (4.3/5)