CIS 1.5 (Science Section)

Brooklyn College

Professor Langsam

 

Assignment #2

 

Wind Chill is the apparent temperature felt on exposed skin due to the combination of air temperature and wind speed. The National Weather Service[1],[2] defines the wind chill index as follows:

 

           

                               

 

where:

 

            Twc is the wind chill index in °F

            Ta is the air temperature in °F

            V is the air speed in miles per hour.

 

 

The formula is not valid if Ta is larger than 50 or if V is larger than 120.  Also note that Fahrenheit and Celsius are related by the following formulas:

 

                                                       

and

 

                                                        

 

Write a program that reads a file, weather.dat, which contains an unknown number of items representing temperatures (in either, Fahrenheit or Celsius) and air speeds (in mph) and calculates the wind chill index for each pair. After printing the wind chill factor for each measurement in the file, print the average temperature, average air speed and average wind chill index.

 

Strategy

 

  1. Read a data pair
  2. Reject values that are invalid (printing an appropriate message)
  3. Determine whether the temperature is in Celsius or Fahrenheit and call a function to convert if necessary.
  4. Call a function that receives the temperature (in °F), the air speed (in mph) and returns the wind chill index (in °F).
  5. Print the temperature (in °F), the air speed (in mph) and the wind chill index (in °F).
  6. Use a counter to count the valid data pairs and an accumulator to sum each of the values needed to calculate the averages.
  7. When there is no more data (you must decide how this is to be determined) print the average temperature, average air speed and average wind chill index.

 

Be sure to comment, neatly format your program, and use meaningful variables as described in class. All output is to be to a file.

 

Use the following data:

 

Temperature                Air Speed

32        F                           20

2          C                          25

75        F                           10

5          C                          35

15        F                           35

25        F                         150

0          F                           25

0          C                          35

-5         F                           45

-1         C                          25

10        F                           15

10        F                           15

 



[1] http://www.nws.noaa.gov/om/windchill/

[2] Osczevski, Randall and Maurice Bluestein. The New Wind Chill Equivalent Temperature Chart. Bulletin of the American Meteorological Society, Oct. 2005, p 1453-1458