Rainfall Data Program . In the Main.java file create a program that • Reads rainfall information from the rainfallData.c

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Rainfall Data Program . In the Main.java file create a program that • Reads rainfall information from the rainfallData.c

Post by answerhappygod »

Rainfall Data Program In The Main Java File Create A Program That Reads Rainfall Information From The Rainfalldata C 1
Rainfall Data Program In The Main Java File Create A Program That Reads Rainfall Information From The Rainfalldata C 1 (41.52 KiB) Viewed 26 times
rainfallData.csv screenshot
Rainfall Data Program In The Main Java File Create A Program That Reads Rainfall Information From The Rainfalldata C 2
Rainfall Data Program In The Main Java File Create A Program That Reads Rainfall Information From The Rainfalldata C 2 (54.46 KiB) Viewed 26 times
Rainfall.java class
public class Rainfall {
public int year;
public double[] data;
public Rainfall(double[] array) {
data = array;
}
public double getYearlyTotal() {
double totalRain = 0;
for(int i = 0; i < data.length; i++) {
totalRain = totalRain + data;
}
return totalRain;
}
public double getMonthlyAvg() {
return getYearlyTotal() / data.length;
}
public int getHighestMonth() {
double highestRain = data[0];
int highestMonth = 1;
for(int i = 0; i < data.length; i++) {
if(data > highestRain) {
highestRain = data;
highestMonth = i + 1;
}
}
return highestMonth;
}
public int getLowestMonth() {
double lowestRain = data[0];
int lowestMonth = 1;
for(int i = 0; i < data.length; i++) {
if(data < lowestRain) {
lowestRain = data;
lowestMonth = i + 1;
}
}
return lowestMonth;
}
}
Rainfall Data Program . In the Main.java file create a program that • Reads rainfall information from the rainfallData.csv file. o the file includes data of monthly rainfall totals in millimeters (mm) for several years. o open the file and get a sense of its content For each year of data (each year found in the data file (rainfallData.csv)) your program should: o use the getYearlyTotal method and prints out the total rainfall for that year o use the getMonthly Avg method and prints out the average monthly rainfall for that year o use the getHighestMonth method and prints out the month number (1,2,.,12) with the highest total rainfall o use the getLowestMonth method and prints out the month number (1,2,.,12) with the lowest total rainfall Make sure you add the suitable exception handling blocks i.e., try and catch blocks when dealing with input from a file.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 Year, January, Febuary, March, April, May, June, July, August, September October, November, December 2003,82.3,78.8,95.6,93.5,72.9,82.7,63.6,99.2,84.2,67.7,105.1,100 1997, 112.8, 100.1,90,106.3,67.2,101.5,96.7,110.2,107.4,107.2,86.7,99.1 1993,71.6,112.8,82,111.4,94.2,97.2,74.7,114.7,110.5,108.4,117.1,78.2 1995,94.5, 119.6,91.5, 111.2,122.2,83,75.8,78.5,94.6,77.4,107,101.4 1985,94.5,91.9,72.4,82.9,122.1,106.1,85.4, 119.4,87.2, 111.8,91.3,72.6 2012,94.1, 115.2,81.7,81.8,69.8,99.3,65.1,82,99.4,128.1,95.2,97.9 2001,100.8,80.3,79.4,103.2, 110.2,98,86.4, 112.8,97.8, 116.6, 116.1,77.8 1992,82.8,74,72.6,99.4,74.5,85.7,67.9,110.2, 114.7,86.6,80.3,102.7 2005, 101.2,109.8,91.1,86.7,91.9,80.3,80.4,108.3,115.8, 107,85.6, 104.7 2002,72.6,111.9, 103.4,91.9,69.8,93,97.2, 117.7,100,59.8,82.9,94 2010,84.9,76.8,72.3,94.9,74.4,88.3,114.5,103.6,98.2,85.2,98.8, 114.6 2007, 104.3,95.6,70.6,84.3, 86.6,86,78.5,114.3,105,105.1,116.2, 104.6 1999,102.8, 118.6,83.2,91.8,86.3, 101.9,80.7,100.6, 106.1,126.4,105.4,108.8 1996, 115.5,86.2,92.4, 118.9,117.4,96.9,90.2,103,109.3, 106.8, 102.7,98.3 2009,95,97.7,80.6,83.3,86, 100.2,69.5, 111.4,111.2,93.1,83.8,99.5 2000, 110.7,93.2,103.9,103.8,124,91.8,184,117.8,90.5,66.6,85.8,119.4 2006,84.5,116.2,93.7, 110.9,83.7, 110.9,98.8, 104.5,87.8,60.5, 110.2,111.6 2004,78.3,85.4,96.6, 102.6,68.7,84.8, 119.7,103.8,92.4, 119.5,88.7,97.1 1994, 118.5, 110, 102.4,99.5, 117.1,83.1,85.8, 101.9,106.9,61.3,83,87.9 1989,102.3,113.1,101.2,90.2,80.9,106.3,79.3,87.3,95.6,123.5,107.2,82.9 2013,91.1,71.6,94.6,103, 107.6,90.5,89.1,78.2,110.9,75.5,118.7,97.8 2011, 109.8,76.1,78.8, 117.9,86,83.9,90.4,85.6,109,90.3,99.2,73.6 2008,94.5,79.5,97.1,83.1,75.4,85.8,81.2,102.7,110.5,120,90.2,87.7 1998,115.1, 84.5,70,104,89.8,109.8,74.6,112.2,97.9, 134.8, 109.5,87.3 1966,76.3,105.8,93.8, 86, 105.7,91.7,88.8, 88.2,114.6,117,86.8,95.7 1984,83.5,98.8,87.4,117.1,72.9,189.1,67.3, 82.1,88,115.6,110.7,109.1 15 16 17 18 19 20 21 22 23 24 25 26 27
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply