
      PROGRAM QUAD1
************************************************************************
* Program to solve a quadratic equation using the quadratic formula.   *
* Variables used are:                                                  *
*     A, B, C      : the coefficients of the quadratic equation        *
*     DISC         : the discriminant, B ** 2 - 4 * A * C              *
*     ROOT1, ROOT2 : the two roots of the equation                     *
*                                                                      *
* Input:  The coefficients A, B, and C                                 *
* Output: The two roots of the equation or the (negative) discriminant *
*         and a message indicating that there are no real roots        *
************************************************************************

      REAL A, B, C, DISC, ROOT1, ROOT2

* Get the coefficients
      PRINT *, 'ENTER THE COEFFICIENTS OF THE QUADRATIC EQUATION'
      READ *, A, B, C

* Calculate the discriminant
      DISC = B ** 2 - 4.0 * A * C

* Check if discriminant is nonnegative.  If it is, calculate and
* display the roots.  Otherwise display the value of the discriminant
* and a no-real-roots message.
      IF (DISC .GE. 0) THEN
         DISC = SQRT(DISC)
         ROOT1 = (-B + DISC) / (2.0 * A)
         ROOT2 = (-B - DISC) / (2.0 * A)
         PRINT *, 'THE ROOTS ARE', ROOT1, ROOT2
      ELSE
         PRINT *, 'DISCRIMINANT IS', DISC
         PRINT *, 'THERE ARE NO REAL ROOTS'
      END IF

      END
