! Adapted from http://www.aspire.cs.uah.edu/textbook/fortran8008.html ! This program allows the user to input the number of degrees in an angle ! and then computes the cosine, sine, and tangent. It continues until the ! user inputs "n" or "N". PROGRAM angle IMPLICIT none ! Type variables. REAL :: cosine, sine, tangent, degrees REAL :: pi = 3.141592 CHARACTER :: choice DO ! Enter and read the number of degrees in the angle. PRINT *, "Enter the number of degrees in the angle." READ *, degrees ! Convert number of degrees in angle to radians. degrees = degrees*(pi/180) ! Use intrinsic functions to compute values. cosine=cos(degrees) sine=sin(degrees) tangent=tan(degrees) ! Print results. PRINT *, "cosine=", cosine, " sine=", sine, " tangent=", tangent ! Give user chance to exit program. PRINT * PRINT *, "Would you like to do this again?" PRINT *,"(Press n to exit - any other key to continue.)" READ *, choice ! Exit loop if the value in choice is N or n. IF (choice == "N" .or. choice == "n") EXIT END DO STOP END PROGRAM angle