Question: In this question you are required to define a class named Rainfall that contain the following: Define private instance variable array for rainAmount and
In this question you are required to define a class named Rainfall that contain the following: Define private instance variable array for rainAmount and for month Name. You may consider these two array as parallel array. Example: private String monthName []; Define default constructor and constructor that takes two arguments for rain amount and name of the month to initialize the instance variables. Define getter and setter methods for each instance variable. Define public method compute TotalRainfall to calculate and return the amount of rain. Define public method computeAverageRainFall that calculate and return the average rainfall for a year. . Define computeMinRainFall and computeMaxRainFall mehods. Define toString() and equals () method also. . 1. Write the code for the class Rainfall as described. 2. Write a TestRainfall class with main method that creates two Rainfall objects and invokes all methods of Rainfall class 3. Create an array of ten Rainfall objects. After creating this array, use a loop to print all ten elements. java output
Step by Step Solution
3.31 Rating (151 Votes )
There are 3 Steps involved in it
Below is the Java code for the Rainfall class and the TestRainfall class public class Rainfall private double rainAmount private String monthName Default constructor public Rainfall rainAmount new dou... View full answer
Get step-by-step solutions from verified subject matter experts
