      PROGRAM LABEXM
************************************************************************
*    PROGRAMMER: B. Alex Bridges
*    CLASS:      9:00AM
*    PROGRAM:    LABEXM.F
*    DUE DATE:   03/18/99
*
* Program Description:
*    This program reads car mileage information from a data file.  It 
*    then uses that information to determing MPG both individually and
*    overall.
* Variables:
*    NAMEF   : student's first name
*    NAMEL   : student's last name
*    CLASS   : student's hour of class
*    LIMIT   : max. sets of data
*    MILESI  : individual number of miles traveled
*    MILEST  : total number of miles traveled
*    GASI    : individual gallons of gas used
*    GAST    : total gallons of gas used
*    MPG     : miles per gallon
*    I       : loop counter
* Input  : NAMEF,NAMEL,CLASS,MILESI,GASI
* Output : MPG,MILEST,GAST
************************************************************************

        CHARACTER*5 NAMEF,NAMEL*8,CLASS*6
        PARAMETER (LIMIT = 10)
        REAL MILESI,MILEST,GASI,GAST,MPG
        INTEGER I

* open the data file
        OPEN (UNIT=12, FILE="labexm.dat")

* read in values for name and class hour
        READ (12, 5), NAMEF,NAMEL,CLASS
 5      FORMAT (A5,A8,A6)

* write the header
        PRINT '("* * * * KETTERING UNIVERSITY COMPANY CAR MILEAGE ",
     1           "REPORT * * * *",//,
     2          "PROGRAMMED BY: ",A,A,"- ",A,//,
     3          " DATA",T10,"MILES",T25,"GALLONS OF",T40,"MILES",/,
     4          " SET",T10,"TRAVELED",T25,"GASOLINE USED",T40,
     5           "PER GALLON",/,
     6          "----------------------------------------------------",
     7           )',
     8            NAMEF,NAMEL,CLASS

* loop until limit reached
        DO 10 I = 1, LIMIT
*  => read in values for individual data
        READ (12, 20), MILESI,GASI
 20     FORMAT(F4.0, F3.1)

*  => determine individual MPG
        MPG = MILESI / GASI

*  => print individual data
        PRINT '(1X,I1,T11,F4.0,T26,F4.1,T40,F5.1)', I,MILESI,GASI,MPG

*  => add individual data to totals
        MILEST = MILEST + MILESI
        GAST = GAST + GASI
 10     CONTINUE

* determine total MPG
        MPG = MILEST / GAST

* print totals
        PRINT '("----------------------------------------------------",/
     1          "Totals",T10,F5.0,T25,F5.1,T40,F5.1," Overall",/,
     2          T40,6X,"Average")', MILEST,GAST,MPG

* write end of program message and close the data file
        PRINT '(/,T13,"* * * *  END OF MILEAGE REPORT  * * * *",/)'
        CLOSE(12)

        END
