PROGRAM Complex_Quadratic_Equations
!-----------------------------------------------------------------------
! Program to solve a quadratic equation having complex coeffieicnts
! using the quadratic formula.  Variables used are:
!    A, B, C        : the coefficients of the quadratic equation
!    Discriminant   : the discriminant, B ** 2 - 4 * A * C
!    Root_1, Root_2 : the complex roots of the equation
!
! Input:  The coefficients A, B, and C
! Output: The two roots of the equation 
!-----------------------------------------------------------------------

  IMPLICIT NONE
  COMPLEX :: A, B, C, Discriminant, Root_1, Root_2

! Get the coefficients

  PRINT *, "Enter the coefficients of the quadratic equation"
  READ 5, A, B, C
  5 FORMAT(6F3.1)

! Calculate and display the roots

  Discriminant = SQRT(B**2 - 4.0*A*C)
  Root_1 = (-B + Discriminant) / (2.0 * A)
  Root_2 = (-B - Discriminant) / (2.0 * A)
  PRINT *, "The roots are:"
  PRINT 10, Root_1, Root_2
  10 FORMAT (5X, F7.3, ' +', F7.3, 'i')

END PROGRAM Complex_Quadratic_Equations