Due: Friday, 11 February 2005 by 10 a.m.
For this homework, you will write a program that will compute the wind chill temperature. Given an ambient temperature (i.e. the temperature without the wind) and the wind speed (in miles per hour (mph)), the wind chill temperature is how cold the wind feel like to human skin. For example, given a temperature of 19° Fahrenheit and a wind of 11 mph, the wind chill temperature makes it feel like 7° Fahrenheit (-14° Celsius).
The program will have the following steps
These formulae are needed for this assignment. The formula for the wind chill temperature, obtained from here, is:
windchill = 35.74 + 0.6215*t - 35.75*v0.16 + 0.4275*t*v0.16
Where windchill is the wind chill temperature, t is the ambient temperature (in Fahrenheit) and v is the wind speed (in mph). To compute an exponent in Java, use the Math.pow() method. For example, if the wind speed was stored in a double variable v, then Math.pow(v,0.16) would compute v0.16.
To convert a temperature in Fahrenheit to a temperature in Celsius, the formula is:
c = 5 * (f - 32) / 9
Where c is the temperature in Celsius, and f is the temperature in Fahrenheit.
All values should be printed out rounded to the nearest integer. This can be done by calling the Math.round() method. For example, consider the following code:
double d = 3.6; int a = (int) Math.round(d); int b = (int) Math.round(-d); System.out.println (a + ", " + b);
This will print out 4, -4. Thus, it will be easiest to compute the temperatures as doubles, then round them to the nearest integer. Note that Math.round() returns a long, and you need to cast it to an int, as done above. Also note that negative numbers are rounded away from zero, so that -3.6 is rounded to -4, not to -3.
We have provided a WindChill.java file for you to start with. Changing the class name will cause a loss of lots of points.
Look at the code for BMICalculator.java (page 75 of the textbook, and available online here) for an idea how to start, as that program is somewhat similar to the one that must be written for this homework. The 8 parts of the main() method for BMICalculator.java (each part is separated by a blank line in the textbook) will be replaced by the 9 parts (mentioned above) for WindChill.java.
The following are considered good programming practices. All homeworks and lab quizzes must include these whenever possible. Not including them will receive points off from the grade. Note that the BMICalculator.java program (on page 75 of the textbook) is an example of a program that follows all these practices.
The following is a sample execution run of the WindChill program. The red text is the input that the user entered.
This program will compute the wind chill temperature What is the temperature in Fahrenheit? 19 What is the wind speed in mph? 11 You entered a ambient temperature of 19.0 degrees Fahrenheit and a wind speed of 11.0 mph The wind chill temperature is 7 degrees Fahrenheit The wind chill temperature is -14 degrees Celsius
Note that a temperature of -13 is also acceptable (depending on how you do your rounding, you may end up with either).
The following is the criteria that the graders will be looking at when the homework is graded. Note that these criteria will not be provided on the other homeworks, only on this first one. Also, the points for each of the following criteria have not yet been determined.
If your program does not compile, you will receive 25 points off!
When you are finished, submit the WindChill.java file.