! 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 7.10. Encapsulated Polar data type.
  program H10
    use H10M
    implicit none
    real, parameter :: DEG = 180.0 / PI
    real :: A1, F1, A2, F2
    type (Polar) :: P1, P2, P3
! start program H10
    do
      write (unit = *, fmt = *) " Please enter Amplitude and Phase (degrees) of"
      write (unit = *, fmt = *) " two polar numbers. To stop, enter 0,0,0,0 "
      read (unit = *, fmt = *)  A1, F1, A2, F2
      if (A1 == 0) then
        exit
      end if
      P1 = Make_Polar( A1, F1 / DEG )
      write (unit = *, fmt = *) " Polar: ", Amplitude( P1 ), Phase( P1 )
      P2 = Make_Polar( A2, F2 / DEG )
      write (unit = *, fmt = *) " Polar: ", Amplitude( P2 ), Phase( P2 )
      P3  = P1 + P2
      write (unit = *, fmt = *) " Sum: ", Amplitude( P3 ), Phase( P3 )* DEG
      P3 = P1 - P2
      write (unit = *, fmt = *) " Difference: ", Amplitude( P3 ), Phase( P3 ) * DEG
      P3 = P1 * P2
      write (unit = *, fmt = *) " Product: ", Amplitude( P3 ), Phase( P3 )* DEG
      P3 = P1 / P2
      write (unit = *, fmt = *) " Quotient: ", Amplitude( P3 ), Phase( P3 )* DEG
      P3 = P1 ** 3.0
      write (unit = *, fmt = *) " Cube: ", Amplitude( P3 ), Phase( P3 )* DEG
    end do
    stop
  end program H10
