C     .TITLE MPG
C
C   4 JUN 75 - PAUL HENDERSON
C
      REAL MILES,GALS,COST,MPG
      REAL TOTM/0.0/,TOTGAS/0.0/,PREVM/0.0/
      CHARACTER*9 DATE
      CHARACTER*39 COMENT
      CHARACTER*80 LINE
C
C  READ INITIAL RECORD TO START THINGS PROPERLY
C
      READ (5,*) LINE
      READ (LINE,*) DATE
      READ (LINE,99) LINE
      READ (LINE,*) PREVM
      READ (LINE,98) COMENT
      WRITE (6,95) DATE,PREVM,COMENT
C
   1  READ (5,*,END=7) LINE
      READ (LINE,*) DATE
C
C  NOW IGNORE THE DATE PART OF THE INPUT LINE
C
      READ (LINE,99) LINE
      READ (LINE,*) MILES,GALS,COST
      READ (LINE,98) COMENT
C
C  PERFORM THE CALCULATIONS
C
      DM     = MILES  - PREVM
      TOTM   = TOTM   + DM
      TOTGAS = TOTGAS + GALS
      MPG    = DM/GALS
C
      WRITE (6,97) DATE,MILES,GALS,DM,MPG,COST,COMENT
      PREVM = MILES
      GO TO 1
C
   7  MPG = TOTM / TOTGAS
      WRITE (6,96) TOTM,MPG
      STOP 7
C
  95  FORMAT (T5,'DATE',T12,'MILEAGE GALS  DIST  MPG',T37,'COST',
     * T44,'COMMENTS'//,1XA9,F8.1,T42,A39)
  96  FORMAT (//' TOTAL MILES',F8.1,'; OVERALL MILES PER GALLON',F5.1)
  97  FORMAT (1XA9,F8.1,F5.1,F6.1,F5.1,F6.2,1XA39)
  98  FORMAT (21XA39)
  99  FORMAT ( 9XA71)
      END
