Indiana University of Pennsylvania
Computer Science Department
CO 110    Fall 86

   Programming Assignment #1

    Winter isn't here yet; but it is certainly coming.  And when winter does get here, we will be talking about cold temperatures and wind-chill once again.  As you know, "wind-chill" refers to how cold it feels rather than what the actual temperature is.  The harder (faster) the wind blows, the greater the difference between the actual temperature and the wind-chill temperature.

    On the next page is a FORTRAN program that prints out a table of wind- chill temperatures when you enter an actual  temperature.  The temperature that you enter must be between 40oF and -40oF.  The table shows the wind-chill temperatures for wind speeds of 5 to 45 miles per hour in increments of 5 mph.   Note:  the wind chill values in the table are NOT accurate; they are only approximate.

    Your assignment is to create a file with this program and your added comments in it and to run the program by specifying four temperatures when the program asks you to enter them.  The comments that you add must include the standard ones that identify you, the program and your section and the data table comments.  The four temperatures that you must specify when the program runs are 22o, 5o, -30o and 50o, in that order.

    In detail, here is how the program works.  It first prints a message to request that a temperature be entered.  If the temperature is greater than 40o or less than -40o, a message is displayed and the program terminates.  Otherwise, the Celcius temperature that is equivalent to the entered temperature is calculated using the formula:    Celcius = 5/9 (Fahrenheit - 32)
and both temperatures are displayed.  There follows a loop in which the wind- chill temperatures in Celcius and Fahrenheit are calculated for wind speeds of 5 to 45 mph.  The Fahrenheit wind-chill temperature is composed of two factors:  a wind factor that is 4% of the wind speed and the effect measure and a coldness factor that is 3% of a temperature difference and the effect measure.  The wind-chill temperature is the entered temperature minus a term that involves the sum of these factors.  Each time through the loop the wind speed is increased by 5 mph and the effect factor is reduced by .05.  When the loop finishes and the table is complete, the program again requests that a temperature be entered.

    At the bottom of the next page is a flowchart for the wind-chill program.   This flowchart is included so that you can see how a real program is flowcharted and to give you experience in seeing an algorithm in flowchart form.   Its only purpose here is to help you understand the program.

    When you have the program working, compile it at the terminal with the LS option, then run it and and enter the four specified data values.  Turn in the program listing and the execution output on a contiguous piece of paper. Be sure to print the following information in LARGE BLOCK LETTERS on the outside page of your program listing.

C    YOUR NAME
C    DATE      PROGRAM NUMBER
C    CO 110    RECITATION SECTION NUMBER
     INTEGER TEMP, CTEMP, SPEED, FCHILL, CCHILL
     REAL COLDF, WINDF, EFFECT
3     PRINT*, 'ENTER THE TEMPERATURE'
     READ*, TEMP
     IF (TEMP .GT. 40) THEN
         PRINT*, 'TEMPERATURE TOO HIGH'
         STOP
     ENDIF
     IF (TEMP .LT. -40) THEN
         PRINT*, 'TEMPERATURE TOO LOW'
         STOP
     ENDIF
     CTEMP = 0.5556 * (TEMP - 32)
     EFFECT = 1.0
     SPEED = 5
     PRINT*
     PRINT*, 'WINDCHILL FOR ', TEMP, 'F   (CELCIUS) ', CTEMP, 'C'
     PRINT*
     PRINT*, 'SPEED     CHILL (F)     CHILL (C)'
9     IF (SPEED .LE. 45) THEN
         WINDF = SPEED * EFFECT * .04
         COLDF = (35 - TEMP) * .03 * (1.0 - EFFECT)
         FCHILL = TEMP - 35 * (WINDF + COLDF)
         CCHILL = 0.5556 * (FCHILL - 32)
         PRINT*, SPEED, '         ', FCHILL, '         ', CCHILL
         SPEED = SPEED + 5
         EFFECT = EFFECT - 0.05
         GO TO 9
     ENDIF
     GO TO 3
     END