CS 206: Data Structures
Exercise#12
Due on Thursday, March 27
This exercise is a tutorial on writing Java applications, and learning how to do input and output of data from files, and how to do tokenizing to extract data from strings. You will be writing three versions of a program that does these things in gradually progressive steps. The tutorial materials, along with the programs will be provided as handouts during class on Tuesday, March 25.
The data you will be using is weather data on Philadelphia (obtained from the National Weather Service) for every day starting from the year 1872 all the way up to 2001 (I will add the 2002 and 2003 data to this in the next few weeks).
Here is what you have to do:
Step by step, read each version of the program (Version 0.0 through 0.2) one at a time, understand the material and then implement it. Submit as proof, a printout of the Console window, and/or the application window. Modify the program(s) so that it prints out the data for January 1, 1900 and January 1, 2000.
After you have completed the three versions, extend the program to Version 0.3 to include a class called DailyWeather. Objects of the class contain the weather information for 1 day (data, high, low, precip, and snow). Define all the needed methods (especially toString) and demonstrate by creating the Version 0.3 that uses the DailyWeather class (functionally it would be the same as Version 0.2).
Click here to download the weather data file.
Notes:
To create an application project, follow the same procedure as for creating applets in Code Warrior. I.e., start a new project, specify a project name, pick the J2SE Stationery. When the project opens up, it opens as TrivialApplication.java. You should rename the class name and the name of the file. Also, select the Target Tab in the project window, double-click on the Java Application Release. You will get a dialog window showing TrivialApplication as the name of the Main application class. Change it to the name of your main class. Then run it to make sure the project is configured properly.