Question: Write a program that will accept from the user a text file containing hurricane data along with an output filename. The data consists of the
Write a program that will accept from the user a text file containing hurricane data along with an output filename. The data consists of the year, the number of storms, the number of hurricanes, and the damage in millions of US Dollars. The first line contains the word Years followed by the first year listed and the last year listed separated by tabs. The following lines contain the data separated by tabs. A sample text file is available in this submission. The program must have a method named parseData (below) which reads a file containing text. parseData will take two File parameters. You may create a main method for testing but the main method will not be evaluated when grading this assignment. parseData will be called directly. public static void parseData(File inputFile, File outputFile){ //Your code here } The program will read in the data from the file into four different arrays: one for each of the data items listed. The array length can be determined from the first line of the input data that states the year range for the data. The program will then calculate the average number of storms per year, average number of hurricanes per year, and average damage costs per year. The averages will be to two decimal places based on the input data given. The program will also identify the year or years with the most number of storms and the year or years with the most number of hurricanes. You will use two methods to generate this information. One method being calculateAverage and the other being findHighest. These methods will be called from the parseData method. public static double calculateAverage (int[] data){ //Your code here } public static String findHighest(int[] storm, int[] year){ //Your code here } The program will write the results to the given outputFile parameter. The first line of output will write a header that includes the year ranges for the data given. You will then write the average number of storms, average number of hurricanes, average amount of damage, years with the most numbers of storms, and years with the most number of hurricanes, each on a separate line. Please note that the output of the damage data should show the actual number not the number in millions of US Dollars (If the output is 2, this is really $2,000,000.). Output for the sample file: For the years: 2015 to 1940: The average number of storms was 10.97. The average number of hurricanes was 6.09. The average damage was $4,996,355,263.16. The year(s) with the highest number of storms is: 2005. The year(s) with the highest number of hurricanes is: 2005 1969. Years 2015 1940 2015 12 4 590 2014 9 6 232 2013 13 2 1510 2012 19 10 75000 2011 19 7 21000 2010 21 12 12356 2009 11 3 77 2008 16 8 24945 2007 15 6 50 2006 10 5 500 2005 28 15 115520 2004 15 9 45235 2003 16 7 3580 2002 12 4 1220 2001 15 9 5260 2000 15 8 26 1999 12 8 5532 1998 14 10 3165 1997 8 3 100 1996 13 9 3600 1995 19 11 3729 1994 7 3 973 1993 8 4 57 1992 7 4 26500 1991 8 4 1500 1990 13 8 57 1989 11 7 7670 1988 12 5 59 1987 7 3 1 1986 6 4 17 1985 10 7 3725 1984 13 5 66 1983 4 3 2000 1982 6 2 2 1981 12 7 25 1980 11 9 300 1979 9 5 3050 1978 12 5 20 1977 6 5 10 1976 10 6 100 1975 9 6 490 1974 11 4 150 1973 8 4 18 1972 7 3 2102 1971 13 6 212 1970 10 5 454 1969 18 15 1421 1968 8 4 11 1967 8 6 200 1966 11 7 15 1965 6 4 1445 1964 12 6 515 1963 9 7 13 1962 5 3 2 1961 11 8 406 1960 7 4 393 1959 11 7 22 1958 10 7 11 1957 8 3 152 1956 8 4 25 1955 12 9 960 1954 11 8 781 1953 14 6 1 1952 7 6 3 1951 10 8 0 1950 13 11 31 1949 13 7 59 1948 9 6 18 1947 9 5 136 1946 6 3 12 1945 11 5 80 1944 11 7 165 1943 10 5 17 1942 10 4 27 1941 6 4 8 1940 8 4 9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
