      PROGRAM FAIL
************************************************************************
* Program to read a list of failure times, count them, and find the    *
* mean time to failure.  Values are read until an end-of-data flag     *
* is read.  Identifiers used are:                                      *
*     FAILTM  :  the current fail time read                            *
*     ENDATA  :  a parameter -- the end-of-data flag                   *
*     COUNT   :  the number of failure time readings                   *
*     SUM     :  sum of failure times                                  *
*     MEAN    :  the mean time to failure                              *
*                                                                      *
* Input:  A list of failure times                                     *
* Output: Number of failure times read and their mean or a message     *
*         indicating that no failure times were entered               *
************************************************************************

      INTEGER COUNT
      REAL FAILTM, ENDATA, SUM, MEAN
      PARAMETER (ENDATA = -1.0)
 
* Initialize SUM and COUNT, and read first failure time
 
      SUM = 0
      COUNT = 0
      PRINT *, 'ENTER FAILURE TIME OF ', ENDATA, ' OR LESS TO STOP'
      PRINT *, 'ENTER FAILURE TIME'
      READ *, FAILTM
 

* While not end-of-data, count, sum, and read failure times
 
 10       IF (FAILTM .GT. ENDATA) THEN
         COUNT = COUNT + 1
         SUM = SUM + FAILTM
         PRINT *, 'ENTER FAILURE TIME'
         READ *, FAILTM
      GO TO 10
      END IF
 
* Calculate and display mean time to failure
 
      IF (COUNT .NE. 0) THEN
         MEAN = SUM / COUNT
         PRINT *
         PRINT *, 'NUMBER OF FAILURE TIME READINGS:', COUNT
         PRINT *, 'MEAN TIME TO FAILURE:', MEAN
      ELSE
         PRINT *, 'NO FAILURE TIMES WERE ENTERED.'       
      END IF

      END
