! Program Example from "Essential Fortran 90 & 95" by Loren P. Meissner
! Copyright 1996. Copying for sale requires permission from the author.
! Otherwise, distribution is permitted if these three lines are included.

! Example 3.13. Choose formula for Z according to (X, Y) quadrant.
  program D13
    implicit none
    real :: X, Y, Z
! start program D13
    write (unit = *, fmt = *) " Please enter values of X and Y. "
    read (unit = *, fmt = *) X, Y
    if (Y > 0.0) then  ! Northeast and northwest quadrants
      Z = sqrt( Y )
    else if (X < 0.0) then  ! Southwest quadrant
      Z = Y
    else  ! Southeast quadrant
      Z = X * Y
    end if
    write (unit = *, fmt = *) " Values of X, Y, and Z are: ", X, Y, Z
    stop
  end program D13
