The goals of this assignment are to:
In this assignment, you will write a program that will store weather conditions in a file. You will enter current weather conditions using the keyboard and your program will compute simple statistics on the conditions and record them in a file.
Weatherobject will record the weather conditions at a given time. It will store the following:
hw4<yourname>. In this class, declare a global
Vectorvariable that will contain multiple
Weatherobjects. Also in this class, include the following methods:
readWeather()-- a method that reads the content of your weather data file and stores the content in the global
writeWeather()-- a method that writes the content of the global
Vectorto the weather data file
outputWeather()-- a method that displays all the
Weatherobjects in the global
Vectorto the screen, in a sensible format
inputWeather()-- a method that prompts the user to enter a new
Weatherobject and reads the user's input from the keyboard; and stores the new object in the global
weatherStats()-- a method that computes and outputs the average of the numerical values in the global
Vector: the average temperature, average windchill and average humidity
writeWeather()in that order.
Keyboardclass, for handling the keyboard input. You may modify this code if you want to, but it is not required.
Below is a sample run. The unix command line is highlighted in bold font.
unix$ java hw4sklar enter name of weather data file: w.dat Thu Feb 13 23:09:15 EST 2003 temperature=34 degrees, windchill=15 degrees, humidity=44% Thu Feb 13 23:10:39 EST 2003 temperature=89 degrees, windchill=89 degrees, humidity=98% please input the current weather... conditions: cold temperature: 3 windchill factor: 2 humidity: 1 average temperature = 42.0 degrees, average windchill = 35.333332 degrees, average humidity = 47.666668% unix$ more w.dat 1045195755030 clear 34 15 44 1045195839539 cloudy 89 89 98 1045196213207 cold 3 2 1 unix$Hint! Notice that inside the data file, the date of each observation is stored as a
long-- the number of milliseconds since midnight GMT, Jan 1, 1970.
Your source code (i.e., your
.java file) must be neat and
You must have a header comment and you should comment the end of each
block (i.e., each
This assignment is worth 15 points (out of 100 for the semester). Distribution of points is:
Weather's global variable declarations
Weatherclass, using best object-oriented practices as demonstrated in class