Question
RAINFALL CLASS Write a RainfallDriver class that has the following methods: main which creates an array of rainfall values for a year. Use the following
RAINFALL CLASS
Write a RainfallDriver class that has the following methods:
main which creates an array of rainfall values for a year. Use the following to do so:
double[] rain = {.5,.3,.7,1.2,.1,.8,2.1,.5,3.3,2.8,.9,1.2};
a method that calculates and prints the total rainfall for the year named total()
a method that calculates and prints the average monthly rainfall named average()
a method that determines and print the maximum rain in any one month named max()
a method that determines and prints the minimum rain in any one month named min()
Each of the last four methods will need to define the array as a parameter that is passed in on the method call. So the methods will have a single parameter which is a double[].
After you create the array in main, call each of the four methods so that they can print their information. Check out Ex9PrimitiveArrayWithMethods for an example on how to start.
Sample output:
The total rainfall for the year is: 14.4
The average monthly rainfall is: 1.2
The maximum monthly rainfall is: 3.3
The minimum monthly rainfall is: 0.1
> CRainfallDriver itp120mod5ANSWERS171 RainfallDriver) o main Stringf) void total doublel void o averageldoublel1)kvoid Omaxdoublel) void min(doublelvoidStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started