      PROGRAM ROAD
************************************************************************
* Program to approximate the the volume of dirt to be removed in       *
* constructing a section of highway through a hill.  Identifiers       *
* used are:                                                            *
*     LENGTH : length of the section of road                           *
*     WIDTH  : width of the road                                       *
*     FNAME  : name of data file containing hill information           *
*     NUMPTS : the number of points where height of hill was measured  *
*     DELX   : distance between points                                 *
*     I      : counter                                                 *
*     Y      : the height of the hill                                  *
*     SUM    : sum approximating the integral for cross-sectional area *
*              of the hill                                             *
*                                                                      *
* Input (keyboard): LENGTH, WIDTH                                      *
* Input (file)    : NUMPTS and values of Y (heights of hill)           *
* Output:         : Volume of dirt to be removed                       *
************************************************************************

      REAL LENGTH, WIDTH, DELX, Y, SUM
      INTEGER NUMPTS, I
      CHARACTER*20 FNAME

* Get road information and name of data file containing hill information

      PRINT *, 'ENTER LENGTH AND WIDTH OF SECTION OF ROAD (IN FEET):'
      READ *, LENGTH, WIDTH
      PRINT *, 'ENTER NAME OF FILE CONTAINING HILL INFORMATION:'
      READ '(A)', FNAME

* Open the data file, read the number of points at which height of hill
* was measured and compute the distance between these points

      OPEN (UNIT = 10, FILE = FNAME, STATUS = 'OLD')
      READ (10, *) NUMPTS
      DELX = LENGTH / REAL(NUMPTS - 1)

* Initialize the approximating SUM and X

      READ (10, *), Y
      SUM = Y / 2.0

* Now calculate SUM, which approximates cross-sectional area of hill

      DO 10 I = 1, NUMPTS - 2
         READ (10, *) Y
         SUM = SUM + Y
 10   CONTINUE

      READ (10, *) Y
      SUM = SUM + Y / 2.0
      SUM = DELX * SUM

      PRINT *, 'VOLUME OF DIRT TO BE REMOVED IS APPROXIMATELY '
      PRINT *,  SUM * WIDTH, ' CUBIC FEET.'

      END
