goal.
The goals of this assignment are to:
program.
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.
Weather.
A Weather object will record the weather conditions
at a given time.
It will store the following:
hw4<yourname>.
In this class, declare a global Vector variable
that will contain multiple Weather objects.
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
Vector
writeWeather() -- a method that writes the
content of the global Vector to the weather data
file
outputWeather() -- a method that displays all
the Weather objects in the global
Vector to the screen, in a sensible format
inputWeather() -- a method that prompts the
user to enter a new Weather object and reads the
user's input from the keyboard; and stores the new object in the global
Vector
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
readWeather(),
outputWeather(),
inputWeather(),
weatherStats() and
writeWeather() in that order.
Keyboard class, for handling the
keyboard input. You may modify this code if you want to, but it is
not required.
sample run.
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.
source code.
Your source code (i.e., your .java file) must be neat and
clearly commented.
You must have a header comment and you should comment the end of each
block (i.e., each }).
submission.
Weather.java
Keyboard.java
hw4<yourname>.java
points.
This assignment is worth 15 points (out of 100 for the semester).
Distribution of points is:
Weather's global variable declarations
Weather constructor
Weather
class, using best object-oriented practices as demonstrated in class
hw4<yourname>.main()
readWeather()
writeWeather()
outputWeather()
inputWeather()
weatherStats()