      PROGRAM ROCKET
************************************************************************
* Program to find the average burn rate for each of several kinds of   *
* propellants, using data consisting of a propellant type and burn     *
* rate observed during test firing of a rocket with that type of       *
* propellant.  Identifiers used are:                                   *
*     PROPEL : kind of propellant                                      *
*     NUMPRO : parameter specifying number of kinds of propellants     *
*     COUNT  : COUNT(I) = number of burn rates for propellant I        *
*     SUM    : SUM(I) = sum of burn rates for propellant I             *
*     BURN   : current burn rate being processed                       *
*                                                                      *
* Input:  Propellant types and burn rates (stored in PROPEL and BURN)  *
* Output: For each kind of propellant, the average burn rate or a      *
*         message indicating that no burn rates were read for that     *
*         kind                                                         *
************************************************************************

      INTEGER NUMPRO
      PARAMETER (NUMPRO = 4)
      INTEGER COUNT(NUMPRO), PROPEL
      REAL SUM(NUMPRO), BURN
      DATA COUNT, SUM /NUMPRO*0, NUMPRO*0.0/

      PRINT *, 'ENTER PROPELLANT TYPES AND BURN RATES (0,0 TO STOP)'
      READ *, PROPEL, BURN

* While there is more data, read a propellant type and burn rate,
* increment the appropriate counter, and add the burn rate to the 
* appropriate sum.

10    IF (PROPEL .GT. 0) THEN
          IF (PROPEL .LE. NUMPRO) THEN
              COUNT(PROPEL) = COUNT(PROPEL) + 1
              SUM(PROPEL) = SUM(PROPEL) + BURN
          ELSE
              PRINT *, '*** ILLEGAL PROPELLANT TYPE:', PROPEL
          END IF
          READ *, PROPEL, BURN
      GO TO 10
      END IF

* Calculate and print average burn rates

      PRINT 100
100   FORMAT(//1X, 'FOR PROPELLANT')
      DO 20 PROPEL = 1, NUMPRO
          IF (COUNT(PROPEL) .GT. 0) THEN
              PRINT 101, PROPEL, SUM(PROPEL) / COUNT(PROPEL)
101           FORMAT(1X, I14, ':  AVERAGE BURN RATE IS', F6.2)
          ELSE
              PRINT 102, PROPEL
102           FORMAT(1X, I14, ':  THERE WERE NO BURN RATES RECORDED')
          END IF
20    CONTINUE
      END
