Wind chill values are calculated differently in different parts of the world (and have been calculated differently in the past). For the pusposes of this project, you must use the following formula that was developed for North American air temperatures at or below \(50^\circ\)F and wind speeds above \(3\)mph:
\[ w = 35.74 + 0.6215 \cdot t - 35.75 \cdot v^{0.16} + 0.4275 \cdot t \cdot v^{0.16} \]where \(w\) denotes the wind chill value in degrees Farenheit, \(t\) denotes the air temperature in degrees Fahrenheit, and \(v\) denotes the velocity in miles per hour. For other temperatures and wind speeds, the wind chill value must be the air temperature.
a. A demonstration that you understand the problem. (Note: You may attempt this part of the assignment multiple times. You may not attempt the next part of the assignment until you have earned a grade of 70% on this part.)
b. A demonstration that you understand Java well enough to use it to complete the assignment. (Note: You may attempt this part of the assignment multiple times. You may not attempt the next part of the assignment until you have earned a grade of 80% on this part.)
c. A Java class (named Weather
) that contains a
function for calculating the wind chill value in North America
(from a temperature measured in degrees Fahrenheit and a wind
speed measured in miles per hour)
and
a driver named WeatherDriver
for testing this
class.
d. A Java main class for calculating the wind chill value for several locations and displaying those values on a map.
pa5
) that
will hold all of the files for this assignment.
You must download the following
Map
class:
This class contains the following function:
setTemperature()
which is passed a
String
containing the 4-character International Civil
Aviation Organization (ICAO) code for the weather station and a
double containing the temperature (which can either be the "raw"
temperature or the wind chill value) at that location. This
function does not return anything.
You must also download the following data files to your directory/folder for this assignment:
The first two data files contain weather data in a space-delimited format. The first field contains the 4-character ICAO code for the weather station, the second contains the temperature at that station (in degrees Farenheit), and the third contains the wind speed at that station (in mi/hr). Each line will contain exactly three fields. (You will need to write code that can read these files.)
The third data file contains information about each weather station,
including its location. This file is used by the Map
class. (You do not need to do anything with this file, and must not
edit it.)
The fourth data file contains information about the geographic
boundaries of the Commonwealth of Virginia. This file is used by the
Map
class. (You do not need to do anything with this
file, and must not edit it.)
Finally, you must download the following updated version of the
Text
class:
In addition to the functions in the earlier version, this version also contains the following functions:
readNextLineFrom()
which is passed a
String
containing a file name and returns a String
containing the "next" line in that file.
thereAreMoreLinesIn()
which is passed a
String
containing a file name and returns true
if the file has more lines to be read and false
otherwise.
splitAtSpaces()
which is passed a String
and returns a String[]
containing all of the "words"
in that String
(where the "words" are defined by the spaces
in the that String
). For example,
if splitAtSpaces()
is passed a String
containing
"KSHD 5.0 13.0"
it will return a String[]
in which element 0 is "KSHD"
, element 1 is
"5.0"
, and element 2 is "13.0"
.
toDouble()
which is passed a String
representation
of a double
and returns the corresponding double
value. Note that, unlike toNonnegativeDouble()
, this
function will convert negative numbers. In addition, unlike
toNonnegativeDouble()
, this function returns the
double
constant
named Double.NaN
if
the String
does not represent a number. You can test
to see whether a particular double
value
equals Double.NaN
using the
Double.isNaN(double)
function
which returns true
if the double
values is
not a number and false
otherwise..
You cannot use the
==
operator for this purpose.
Weather
class you must submit it using Web-CAT (and the Blackboard
attestation process). Then, after you complete
the ChillMapper
class you must submit it (along with
the Weather
class) using Web-CAT (and the Blackboard
attestation process).
Weather
class and your
ChillMapper
class independently.
Weather
class. At a minimum, you must test it with the following values (and you
should think about why each of these tests is relevant):
Temperature | Wind Speed | Wind Chill |
20.2 | 17.4 | 5.47 |
40.0 | 10.0 | 33.64 |
51.0 | 20.0 | 51.00 |
20.0 | 3.0 | 20.00 |
-15.0 | 15.0 | -38.61 |
50.0 | 10.0 | 46.04 |
-10.0 | 3.0 | -10.0 |
49.9 | 4.0 | 48.75 |
50.0 | 3.1 | 49.59 |
5.0 | 13.0 | -11.82 |
Note that the expected values above may only be accurate to 2 decimal places. You should think about how you will take that into account in your driver.
To reduce the burden on the Web-CAT server, after writing your own
driver and testing your implementation of the
Weather
class, you should test your code using
PA5cTestSuite.jar. As before, you
will need to copy junit.jar
to the working directory
for this assignment. (PA5cTestSuite.jar
uses the
exact same tests cases as Web-CAT. So, if you code passes these
tests it will pass the Web-CAT tests.) Note that
neither PA5cTestSuite.jar
nor
Web-CAT
will provide any hints if your code fails
a test. You must use your driver to test and debug your code.
ChillMapper
class using test
cases that you create.
After testing your implementation using your test cases, too reduce the burden on the Web-CAT server, you should test your code using PA5dTestSuite.jar. This test suite does provide hints to help you debug your code.
ChillMapper
does not have
specific requirements about functions, you should spend a
considerable amount of time designing this class (i.e., you should
think about what functions you want to include). This class can be
implemented in a variety of different ways, some of which are elegant
and some of which are inelegant. You should not focus exclusively on
getting your code working, you should also focus on making your code
elegant. (Indeed, your grade will be based on the elegance of your
solution. So, even if your code works, you might receive a very low grade
if your solution is not well-designed.)
Also, even though this assignment has been divided into four parts, the last part is considerably more complicated than anything you have done thus far in this course (because you have to both design and implement your solution). Hence, you should start early. You will probably need all of the time between when the first part is due and when the last part is due to complete it.
Weather
class.
Only after the Weather
class has been implemented and tested
should you start on the ChillMapper
class. I recommend
approaching this class as follows:
ChillMapper
class), move the
duplicative code to that function, and call that function.
(Hint: This should involve another loop.)
Copyright 2013