!=====================================================
! example3.f90
! Sakke Karstu
!
! Solves the roots of a quadratic equation 
!
! inputs: a, b, and c, the coefficients in 
! the quadratic equation 
!
! outputs: root1, root2, the roots of the 
! quadratic equation with coefficients a, b, and c
!=====================================================

PROGRAM QuatraticEquation
   IMPLICIT NONE

   REAL :: a, b, c
   REAL :: d
   REAL :: root1, root2 

! read in the coefficients a, b, and c

   WRITE(*,*) 'Type in A, B, and C, Please: '
   READ(*,*) a, b, c

! compute the square root of discriminant and store in d

   d = SQRT( b * B - 4 * a * c )

! solve for the roots one at a time
   
   root1 = ( -b + d ) / (2.0 * a)
   root2 = ( -b - d ) / (2.0 * a)

! display results

   WRITE(*,*) 
   WRITE(*,*) 'The roots are ', root1, ' and ', root2

END PROGRAM QuatraticEquation
