Create a main Java application called A19006
Create a /data folder. This is where you will have your FBIN.txt and FBOUT.txt files for this assignment.
In your main Java application.
Declare a string array called aryAltitudes that contains the nine altitudes as two character strings. (i.e. "03", "06", "09", etc)
Declare other variables as needed.
Open an output file called FBOUT.txt and write a heading (see below) using a PrintWriter object.
Instantiate a Stations object (see below) called db and hand it the file name of FBIN.txt in your data folder.
Prompt for Station ID using a JOptionPane object and store the result in strStaID.
If the station ID exists in the Stations object:
Using your Stations object, get the station weather for the Station ID stored in staList.
Write the number of records in the Stations object to the output file.
Write the station weather to the output file.
Instantiate a NWSFB object (from last assignment with all of the exceptions handled) called fb using the station weather that you got from the stations object
Create a formatted string (see below) of the wind direction, speed, and temperature for each of the nine altitudes and write them to the output file. Do not use the fmtWeatherReport() method that was created in the previous assignment. Construct the string in the main application and add it to the file.
Don't forget to close your output file.
Create a class called Stations that will:
Create two ArrayList objects (one called staList and the other staIndex).
Have a constructor that will accept a string representing the full path to the FBIN.txt file and store it in an instance variable called strFilePath then read the file record by record and add each station weather string to the staList and store the corresponding station ID to the staIndex array list.
Create a length() function that will return the number of stations stored in the arraylist.
Create a getStaWea(strStationID) function that will accept the station id as a parameter and return the full station weather as a string. You will likely have to use the .indexOf() and .get() methods of the ArrayList class (which means you will have to look up indexOf in the Java API.
Create an exists(strStationID) function that checks to see if the station ID exists in the staIndex arraylist.
Clean up your NWSFB class and submit it along with your project.
Add the Javadoc comments to your program and generate the documentation. See the tutorial above on how to do that. In general, you are going to create a /doc folder, place an options.txt file in it and then generate the documentation. When you go to compress your assignment into a ZIP file, everything is transported as one unit.
You'll get 1 file (11.3KB)