Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

07.03 Assignment Instructions Instructions: Write an OOP program to calculate the average category, pressure, and wind speed of Atlantic hurricanes that have occurred between a

07.03 Assignment Instructions

Instructions: Write an OOP program to calculate the average category, pressure, and wind speed of Atlantic hurricanes that have occurred between a given year range. Also, tally the number of storms in each category according to the Saffir-Simpson scale.

  1. Create a new project folder called Challenge Program in the Mod07 Assignments folder.
  2. Download the HurricaneTester.java as starter code for your project.
  3. Download the Hurricane.java object class and the HurricaneData.txt file to the new project.
  4. Examine the text file to become familiar with the information it contains. The name, pressure (mb), wind speed (kts), month, and year have been provided.
  5. Write your tester class. Document each section of code. Use for-each loops and traditional for loops where they are appropriate.
  6. Review the code in the starter program that reads all the data from the text file and stores it in arrays.
  7. Convert the wind speed from knots to miles per hour.
  8. The category of each storm is not provided. Use the Saphir-Simpson Wind Speed Scale to determine the category of each storm and assign to an array.
  9. Using the newly assigned arrays, create an ArrayList of Hurricane objects.
  10. Ask the user to provide a range of years. Use this range to create the output. Ensure the user picked years for which you have data.
  11. For the given year range, calculate the average for category, wind speed, and pressure.
  12. Use the Integer.MIN_VALUE and Integer.MAX_VALUE constants. Do not use Java's max() or min() methods.
  13. Print the results in a well formatted, user-friendly fashion. Complete the toString() method in the Hurricane object class. String data should be left justified. Numeric data needs to be aligned on the decimal point. Use the sample below as a guide.

Saphir-Simpson Hurricane Wind Scale: Scale used to categorize hurricanes.

Wind Speed Category
7495 mph 1
96110 mph 2
111129 mph 3
130156 mph 4
157 mph or higher 5

Expected Output: Your program's output should be similar to the following screen shot. Due to the amount of information, only the top and bottom of the output generated is shown in this image.

** * @purpose: Hurricane Object Class * * @author APCS Team * @version FLVS 2020 * */ public class Hurricane { private String name, month; private int year; private int cat; private int pressure; private double windspeed; //constructor - all private instance variables initialized public Hurricane(int y, String n, String m, int c, int p, double w) { this.year = y; this.name = n; this.month = m; this.cat = c; this.pressure = p; this.windspeed = w; } //accessor for year public int getYear() { return year; } //accessor for name public String getName() { return name; } //accessor for month public String getMonth() { return month; } //accessor for category public int getCat() { return cat; } //accessor for pressure public int getPressure() { return pressure; } //accessor for windspeed public double getWindspeed() { return windspeed; } //mutator for year public void setYear(int y) { year = y; } //mutator for name public void setName(String n) { name = n; } //mutator for month public void setMonth(String m) { month = m; } //mutator for category public void setCat(int c) { cat = c; } //mutator for pressure public void setPressure(int p) { pressure = p; } //mutator for windspeed public void setWindspeed (double w) { windspeed = w; } public String toString() { // complete the toString method using String.format() } } 

/** * Starter code for the Hurricane Tester * APCS Team 2020 * */ import java.io.IOException; import java.io.PrintWriter; import java.io.File; import java.util.Scanner; public class HurricaneTester { public static void main(String[] args) throws IOException { //read data from text file & put in an array File fileName = new File("hurricanedata.txt"); Scanner inFile = new Scanner(fileName); int numValues = 0; //count number of lines in text file while (inFile.hasNextLine() ) { inFile.nextLine(); numValues++; } inFile.close(); //initialize arrays based on lines counted in text file int [] years = new int[numValues]; String [] months = new String[numValues]; int [] pressures = new int[numValues]; double [] windSpeeds = new double[numValues]; String [] names = new String[numValues]; //read and assign data from text file to the arrays inFile = new Scanner(fileName); int index = 0; while(inFile.hasNext() ) { years[index] = inFile.nextInt(); months[index] = inFile.next(); pressures[index] = inFile.nextInt(); windSpeeds[index] = inFile.nextDouble(); names[index] = inFile.next(); index++; } inFile.close(); //convert the windspeed, determine categories, calculate sums //create a Hurricane ArrayList using the data above 1995 Jun 987 65 Allison 1995 Jul 973 85 Erin 1995 Aug 929 120 Felix 1995 Aug 968 95 Humberto 1995 Aug 965 95 Iris 1995 Aug 945 130 Luis 1995 Sep 949 100 Marilyn 1995 Sep 987 65 Noel 1995 Sep 916 130 Opal 1995 Oct 956 100 Roxanne 1995 Oct 972 75 Tanya 1996 Jul 960 100 Bertha 1996 Jul 985 75 Cesar 1996 Aug 989 70 Dolly 1996 Aug 933 125 Edouard 1996 Aug 946 105 Fran 1996 Sep 935 120 Hortense 1996 Sep 960 100 Isidore 1996 Oct 960 100 Lili 1996 Nov 983 65 Marco 1997 Jul 986 65 Bill 1997 Jul 984 70 Danny 1997 Sep 946 110 Erika 1998 Aug 954 100 Bonnie 1998 Aug 960 70 Danielle 1998 Aug 985 80 Earl 1998 Sep 937 135 Georges 1998 Sep 975 80 Ivan 1998 Sep 969 90 Jeanne 1998 Sep 970 90 Karl 1998 Oct 995 65 Lisa 1998 Oct 905 155 Mitch 1998 Nov 979 75 Nicole 1999 Aug 944 125 Bret 1999 Aug 942 120 Cindy 1999 Aug 962 90 Dennis 1999 Sep 921 135 Floyd 1999 Sep 930 130 Gert 1999 Oct 958 95 Irene 1999 Oct 979 85 Jose 1999 Nov 933 135 Lenny 2000 Aug 950 110 Alberto 2000 Aug 991 75 Debby 2000 Sep 985 70 Florence 2000 Sep 981 70 Gordon 2000 Sep 943 120 Isaac 2000 Sep 975 80 Joyce 2000 Sep 939 120 Keith 2000 Oct 965 85 Michael 2001 Sep 968 105 Erin 2001 Sep 962 100 Felix 2001 Sep 975 70 Gabrielle 2001 Sep 970 90 Humberto 2001 Oct 948 125 Iris 2001 Oct 982 70 Karen 2001 Oct 933 120 Michelle 2001 Nov 986 65 Noel 2001 Nov 973 80 Olga 2002 Sep 960 80 Gustav 2002 Sep 934 110 Isidore 2002 Sep 980 75 Kyle 2002 Sep 938 125 Lili 2003 Jul 979 80 Claudette 2003 Jul 1000 65 Danny 2003 Aug 986 65 Erika 2003 Aug 939 125 Fabian 2003 Sep 915 145 Isabel 2003 Sep 969 90 Juan 2003 Sep 952 110 Kate 2004 Jul 957 105 Alex 2004 Aug 941 130 Charley 2004 Aug 964 95 Danielle 2004 Aug 935 125 Frances 2004 Aug 985 65 Gaston 2004 Sep 910 145 Ivan 2004 Sep 950 105 Jeanne 2004 Sep 938 125 Karl 2004 Sep 987 65 Lisa 2005 Jul 991 65 Cindy 2005 Jul 930 130 Dennis 2005 Jul 929 140 Emily 2005 Aug 970 90 Irene 2005 Aug 902 150 Katrina 2005 Sep 962 100 Maria 2005 Sep 979 80 Nate 2005 Sep 976 75 Ophelia 2005 Sep 985 70 Philippe 2005 Sep 895 155 Rita 2005 Oct 977 70 Stan 2005 Oct 988 65 Vince 2005 Oct 882 160 Wilma 2005 Oct 962 100 Beta 2005 Nov 981 75 Epsilon 2006 Aug 992 65 Ernesto 2006 Sep 974 80 Florence 2006 Sep 955 105 Gordon 2006 Sep 955 105 Helene 2006 Sep 985 75 Isaac 2007 Aug 905 150 Dean 2007 Aug 929 150 Felix 2007 Sep 985 80 Humberto 2007 Sep 988 65 Karen 2007 Sep 990 70 Lorenzo 2007 Oct 980 70 Noel 2008 Jul 952 110 Bertha 2008 Jul 963 85 Dolly 2008 Aug 941 135 Gustav 2008 Aug 977 75 Hanna 2008 Sep 935 125 Ike 2008 Sep 984 70 Kyle 2008 Oct 958 115 Omar 2008 Nov 970 85 Paloma 2009 Aug 943 115 Bill 2009 Sep 958 105 Fred 2009 Nov 975 90 Ida 2010 Jun 946 95 Alex 2010 Aug 942 115 Danielle 2010 Aug 927 125 Earl 2010 Sep 924 135 Igor 2010 Sep 948 120 Julia 2010 Sep 956 110 Karl 2010 Sep 982 75 Lisa 2010 Oct 976 75 Otto 2010 Oct 981 90 Paula 2010 Oct 977 85 Richard 2010 Oct 989 65 Shary 2010 Oct 985 85 Tomas 2011 Aug 942 105 Irene 2011 Aug 942 120 Katia 2011 Sep 983 70 Maria 2011 Sep 994 65 Nate 2011 Sep 940 120 Ophelia 2011 Sep 976 80 Philippe 2011 Oct 966 100 Rina 2012 Jun 974 75 Chris 2012 Aug 973 85 Ernesto 2012 Aug 965 95 Gordon 2012 Aug 965 70 Isaac 2012 Aug 970 90 Kirk 2012 Aug 968 70 Leslie 2012 Sep 964 100 Michael 2012 Sep 978 80 Nadine 2012 Oct 969 80 Rafael 2012 Oct 940 100 Sandy 2013 Sep 979 80 Humberto 2013 Sep 983 75 Ingrid 2014 Jul 973 85 Arthur 2014 Aug 998 70 Bertha 2014 Aug 965 75 Cristobal 2014 Sep 955 105 Edouard 2014 Oct 983 70 Fay 2014 Oct 940 125 Gonzalo 2015 Aug 960 110 Danny 2015 Aug 986 75 Fred 2015 Sep 931 135 Joaquin 2015 Nov 980 75 Kate 2016 Sep 981 80 Hermine 2016 Oct 963 85 Matthew 2017 Aug 962 110 Gert 2017 Aug 937 130 Harvey 2017 Sep 914 175 Irma 2017 Oct 981 90 Nate 2018 Sep 937 150 Florence 2018 Sep 919 160 Michael 2019 Jul 993 72 Barry 2019 Sep 913 180 Dorian 2019 Sep 950 125 Humberto //user prompted for range of years //print the data } }

Printimage text in transcribed

image text in transcribedPlease help me with this challenge program in Java.

Expected Output: Your program's output should be similar to the following screen shot. Due to the amount of information, only the top and bottom of the output generated is shown in this image. Hurricanes 2003 - 2005 Year Hurricane Category Pressure (mb) Wind Speed (mph) 2003 2003 2003 2003 2003 Claudette Danny Erika Fabian Isabel Juan Kate Alex Charley 1 1 1 4 5 2 3 3 3 4 979 1000 986 939 915 969 952 957 941 92.06 74.80 Y 74.80 143.85 166.86 103.57 126.59 120.83 149.60 2003 2003 2004 2004 2005 2005 2005 2005 2005 Stan Vince Wilma Beta Epsilon 1 1 5 3 1 977 988 882 962 981 80.55 74.80 184.12 115.08 86.31 Average: Minimum: Maximum: 2.7 1 5 955.4 Be2 1000 117.49 74.80 184.12 Summary of Categories: Cat 1: 12 Cat 2:3 Cat 3: 5 Cat 4: 5 Cat 5: 6 c

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Iv Special Issue On Database Systems For Biomedical Applications Lncs 6990

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Christian Bohm ,Johann Eder ,Claudia Plant

2011th Edition

3642237398, 978-3642237393

More Books

Students also viewed these Databases questions

Question

8-6 Who poses the biggest security threat: insiders or outsiders?

Answered: 1 week ago