C---------------------------------------------------------------
C                      
C                --- MATH. 375---FALL 1997---
C
C                         PROJECT I
C
C---------------------------------------------------------------
C       Program to compute the roots of a quadratic to 16 decimals
C---------------------------------------------------------------
	implicit none
        real A,B,C,SIGN,X,E,DISCRIMINANT, R
        write(*,*) ' to exit, type 0 0 0'
  10    continue
        write(*,*) 'A B C ?'
        read(*,*) a,b,c
        if (A .eq. 0) then
           if (b .eq. 0) then
              write(*,*) 'a = b = 0; no roots'
              stop
           else
              x = -c/b
              write(*,*) 'linear case; single root is ',x
              goto 10
           endif
        endif
        B = B/A
        C = C/A
        if (B .eq. 0.) then
           if (c .gt. 0.) then
              x = sqrt(c)
              write(*,*) 'imaginary conjugate roots x = +/-i',x
           else
              x = sqrt(-c)
              write(*,*) 'real symmetric roots x = +/-',x
           endif
           goto 10
        endif
        DISCRIMINANT = (B/2.)**2-C
        write(*,*) 'DISCRIMINANT = ', DISCRIMINANT
        E = -B/2.
        if (DISCRIMINANT .eq. 0.) then
           write(*,*) 'real equal roots x = ',E
           goto 10
        endif
        if (B .gt. 0.) then
          SIGN = -1. 
        else
          SIGN =  1.
        endif
           R = sqrt(abs(DISCRIMINANT))
        if (DISCRIMINANT .lt. 0.) then
C complex roots
           write(*,*) 'complex conjugate roots'
           write(*,*) E,'+/-i ',R   
        else
C real roots
           write(*,*) 'real distinct roots'
          x= E+SIGN*R
           write(*,*) 'x1 = ', x
          x = C/x
           write(*,*) 'x2 = ', x
        endif
        goto 10
        end
