CIS 636 Spring 2006       Assignment 1 – Getting Warmed Up – IDE                                                         100 points

Assigned: 01/17/2006

Due: 01/24/2006 at the start of class 

 

You should work individually on this assignment. Later, you may have the option of working in pairs. 

 

Main Assignment:

The National Weather Service has updated its wind chill factor formula. See hthttp://www.nws.noaa.gov/om/windchill/index.shtml and  hthttp://www.usatoday.com/weather/resources/basics/windchill/wind-chill-formulas.htm. Your current task is to recreate a simple Java Application to calculate Wind Chill Factors for both the old and new formulas. 

The main program will be as written on the attached sheet (we have barely started talking about Java after all). Parts of it can be autogenerated by the IDE. It will obtain from the user the current temperature and wind speed. Then calculate the wind chill factors and display the results (including temperature and wind speed and both wind chill factors).  The USA Today page above has the new and old formulas.  The NWS page above has a chart of wind chill factors and an applet (?) that calculates the new value, so you can check your work.

I have made available to you two I/O classes, RedmondMsgInBasic, and RedmondMsgOut, that take care of a lot of details of  I/O. The RedmondMsgInBasic class has methods that use dialog boxes for input –  readValid, and for output – RedmondMsgOut provides the display method. These will be put in a library project that you may use for much of the early part of the semester until we cover GUI development. 

  

Hand in:

 

Miscellaneous:

·        You haven’t learned much about Java yet. Any problems that you encounter should come from either learning the environment or mistyping of code. If code is a possibility, study what you have against the provided code.

·        You can get my code you need from the assignments page of my WWW site. 

·        You shouldn’t have to change anything in RedmondMsgInBasic and RedmondMsgOut. The recommended methods make some simplifying assumptions, since we haven’t covered exception handling yet. This means that some exceptions will result if the user tries hard enough.  No biggie at this point.

·        Valid temperatures are from –40 to 50 (wind chill is undefined above 50 degrees). Valid wind speeds are from 3 to 105 (wind chills are undefined for wind speed less than 3).  Choices that are invalid shouldn’t cause problems with the program.  RedmondMsgInBasic methods should re-ask if you have copied code correctly.

·        MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors).    

·        Put YOUR NAME, and e-mail address in comments at the beginning of the program.

·        Follow my code even in ways that Java doesn’t care about  (Indentation, comments) as it is important to develop good habits.



/*

 * WindChillDriver.java

 *

 * Created on January 6, 2005, 4:40 PM

 * Created on January 27, 2003, 2:45 PM

 */

 

package windchillp;

 

import IO.RedmondMsgInBasic;

import IO.RedmondMsgOut;

import java.lang.Math.*;

 

/**

 *

 * @author Mike

 */

public class WindChillDriver {

   

    /** Creates a new instance of WindChillDriver */

    public WindChillDriver() {

    }

   

    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

        // wind chill is not defined if temperature is above 50

        double tempF = RedmondMsgInBasic.readValidDouble("What is the current temperature?",

-20.0, 50.0);

        // assume wind speed is a whole number

        // not defined if less than 3

        int wind = RedmondMsgInBasic.readValidInt("What is the current wind speed?", 3, 105);

        double windChill = 35.74 + (0.6215 * tempF)

            - (35.75 * Math.pow(wind, 0.16))

            + (0.4275 * tempF * Math.pow(wind, 0.16));

        double oldWindChill = 0.0817 * ( 3.71 * Math.pow(wind,0.5)

                                        + 5.81 - 0.25 * wind)

                                     * (tempF - 91.4)

                             + 91.4;

        RedmondMsgOut.display("Results: \n     Temperature (F): " + tempF

            + "\n     Wind Speed (mph): " + wind

            + "\n     Wind Chill (F):   " + windChill

            + "\n     Old Wind Chill (F): " + oldWindChill

            );

        System.exit(0);

    }

 

}