PROGRAM Angles_1
!----------------------------------------------------------------------
! Program demonstrating the use of a subroutine PrintDegrees to
! display an angle in degrees.  Variables used are:
!  NumDegrees : degrees in the angle measurement
!  NumMinutes : minutes in the angle measurement
!  NumSeconds : seconds in the angle measurement
!  Response   : user response to more-data question
!
! Input:  NumDegrees, NumMinutes, NumSeconds, Response
! Output: Equivalent measure in degrees (displayed by PrintDegrees)
!----------------------------------------------------------------------

  IMPLICIT NONE
  INTEGER :: NumDegrees, NumMinutes, NumSeconds
  CHARACTER(1) :: Response

  ! Read and convert angles until user signals no more data
  DO
     WRITE (*, '(1X, A)', ADVANCE = "NO") &
           "Enter degrees, minutes, and seconds: "
     READ *, NumDegrees, NumMinutes, NumSeconds
     CALL PrintDegrees(NumDegrees, NumMinutes, NumSeconds)
     WRITE (*, '(/ 1X, A)', ADVANCE = "NO") "More angles (Y or N)? "
     READ *, Response
     IF (Response /= "Y") EXIT
  END DO

CONTAINS

  !-PrintDegrees-------------------------------------------------------
  ! Subroutine to display a measurement of Degrees, Minutes, Seconds 
  ! as the equivalent degree measure.
  !
  ! Accepts:  Degrees, Minutes, Seconds
  ! Output:   Values of Degrees, Minutes, and Seconds and the
  !           equivalent degree measure
  !--------------------------------------------------------------------
  
  SUBROUTINE PrintDegrees(Degrees, Minutes, Seconds)
  
    INTEGER, INTENT(IN) :: Degrees, Minutes, Seconds
  
 PRINT 10, Degrees, Minutes, Seconds, &
           REAL(Degrees) + REAL(Minutes)/60.0 + REAL(Seconds)/3600.0
 10 FORMAT (1X, I3, " degrees", I3, " minutes",  I3, " seconds" &
            / 1X, "is equivalent to" / 1X, F7.3, " degrees")
  
  END SUBROUTINE PrintDegrees
  
END PROGRAM Angles_1
