PROGRAM POLLUTION_INDICES
*********************************************************************
* This program reads any number of pollution levels, computes a     *
* pollution index as their integer average, and then displays an    *
* appropriate air-quality message.                                  *
*                                                                   *
* Constants:  LOW_CUTOFF, HIGH_CUTOFF                               *
* Input:      LEVEL1, LEVEL2, LEVEL3                                *
* Output:     POLLUTION_INDEX                                       *
*             A message describing the air quality                  *
*********************************************************************

   IMPLICIT NONE
   INTEGER, PARAMETER :: &
           LOW_CUTOFF = 35, &        ! parameters giving the low 
           HIGH_CUTOFF = 60          ! and high cutoff points
   INTEGER ::
           LEVEL1, LEVEL2, LEVEL3, & ! height at any time
           POLLUTION_INDEX           ! pollution index

   PRINT *, "Enter negative pollution readings to stop."
   PRINT *, "Enter 3 pollution readings :"
   READ *, LEVEL1, LEVEL2, LEVEL3
   DO WHILE (LEVEL1 >= 0)
      POLLUTION_INDEX = (LEVEL1 + LEVEL2 + LEVEL3) / 3
      SELECT CASE (POLLUTION_INDEX)
         CASE (0 : LOW_CUTOFF - 1)
            PRINT *, "Pleasant condition"
         CASE (LOW_CUTOFF : HIGH_CUTOFF)
            PRINT *, "Safe condition"
         DEFAULT
            PRINT *, "Hazardous condition"
      END SELECT
      PRINT *
      PRINT *, "Enter 3 pollution readings :"
      READ *, LEVEL1, LEVEL2, LEVEL3
   END DO

END PROGRAM POLLUTION_INDICES

