PROGRAM Pollution_Indices
!------------------------------------------------------------------
! Program that reads 3 pollution levels, calculates a pollution
! index as their integer average, and then displays an appropriate
! air-quality message.   Identifiers used are:
!   Level_1, Level_2, Level_3 : the three pollution levels
!   LowCutoff, HighCutoff     : cutoff values that distinguish
!                               between good/fair, and fair/poor
!                               conditions, respectively
!   Index : the integer average of the pollution levels
!
! Input:     The three pollution levels and the cutoff value
! Constants: The two cutoff values
! Output:    The pollution index and a "good condition" message if
!            this index is less than LowCutoff, a "fair condition"
!            message if it is between LowCutoff and HighCutoff, 
!            and a "poor condition" message otherwise
!------------------------------------------------------------------

  IMPLICIT NONE
  INTEGER :: Level_1, Level_2, Level_3, Index
  INTEGER, PARAMETER :: LowCutoff = 25, HighCutoff = 50

! Get the 3 pollution readings
  PRINT *, "Enter 3 pollution readings:"
  READ *, Level_1, Level_2, Level_3

! Calculate the pollution index
  Index = (Level_1 + Level_2 + Level_3) / 3

! Classify the pollution index and display an appropriate
! air-quality message
  SELECT CASE (Index )
     CASE (:LowCutoff - 1)
        PRINT *, "Good condition"
     CASE (LowCutoff : HighCutoff - 1)
        PRINT *, "Fair condition"
     CASE (HighCutoff:)
        PRINT *, "Bad condition"
  END SELECT

END PROGRAM Pollution_Indices
