Question: Can I get a second class for this, to test with this output. import java.io.*; import java.util.*; class RainFall{ private double[] data; public RainFall (double[]

Can I get a second class for this, to test with this output.

Can I get a second class for this, to test with this

import java.io.*; import java.util.*;

class RainFall{

private double[] data;

public RainFall (double[] array){ data = new double[array.length]; for (int i = 0; i data[i] = array[i]; } public double totalRainFall(){ double sum = 0; for (int i = 0; i sum = sum + data[i]; return sum; } public double average(){ double sum = 0; for (int i = 0; i sum = sum + data[i]; return sum/data.length; } public int mostRain(){ double max = 0; int index = 0; for (int i = 0; i if (data[i] > max){ max = data[i]; index = i; } return index; } public int leastRain(){ double min = 100; int index = 0; for (int i = 0; i if (data[i] public ArrayList monthsHigherThanAverage(){ ArrayList list = new ArrayList(); double avg = average(); for (int i = 0; i if (data[i] > avg){ list.add(i); } } return list; } double getValue(int a){ return data[a]; } String getName(int a){

String res = ""; switch(a){ case 1 : res = "January"; break; case 2 : res = "February"; break; case 3 : res = "March"; break; case 4 : res = "April"; break; case 5 : res = "May"; break; case 6 : res = "June"; break; case 7 : res = "July"; break; case 8 : res = "August"; break; case 9 : res = "September"; break; case 10 : res = "October"; break; case 11 : res = "November"; break; case 12 : res = "December"; break; } return res; } }

Test data from the intializer list... The total rainfall for this year is 35.0 The average rainfall for this year is 2.9 The month with the highest amount of rain is October with 4.3 inches. The month with the lowest amount of rain is January with 1.6 inches There are 5 months whose rainfall are higher than average: April June July October Decemeber 3.7 3.7 Test data read from the file... The total rainfall for this year is 34.1 The average rainfall for this year is 2.8 The month with the highest amount of rain is August with 4 inches The month with the lowest amount of rain is February with 1.5 inches. There are 5 months whose rainfall are higher than average: April July August September October

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!