***********************************************************************
*
*     Deriv.f
*     A program created for Programming Workshop Spring 06
*     At Marlboro College taught by Jim Mahoney
*
*     Written by Jesse Welch
*     
*     This program will take input from the user about the function 
*     in question.  There are 6 choices currently for functions to
*     use.  The program will deliver a value for functions at a 
*     point given by the user.  
*
*     Version History:
*     1.0 - Output trig function values from user input
*     1.1 - Added in logarithmic functions
*     2.0 - Added in the derivative option
*     
***********************************************************************
      PROGRAM Deriv
      
      REAL ANGLE
      REAL VALUE
      INTEGER PICK1, PICK2, PICK3, PICK4, PICK5, PICK6, PICK7
      
      WRITE(*,*) 'Do you want a ',' 1: Derivitive   ',' 2: Value'
      READ(*,*) PICK1

      IF(PICK1 .EQ. 1)THEN
         WRITE(*,*) 'Do you want a ','1: Trig Function  ',' 2: Log Funct
     $ion'
         READ(*,*) PICK2
         IF(PICK2 .EQ. 1)THEN
            WRITE(*,*) '1: Sin  ',' 2: Cos  ',' 3: Tan   '
            READ PICK3
         ELSE
            WRITE(*,*) '1: Log base e  ',' 2: Log base 10 ',' 3: Exp '  
            READ PICK4
         ENDIF
         
         IF(PICK3 .EQ. 1)THEN
            WRITE(*,*)  'What is the angle you wish to calculate?'
            READ(*,*) ANGLE
            WRITE(*,*) 'The derivative of Sin(',ANGLE,') is : ' , COS(AN
     $           GLE)
         ELSE IF(PICK3 .EQ. 2)THEN
            WRITE(*,*)  'What is the angle you wish to calculate?'
            READ(*,*) ANGLE
            WRITE(*,*) 'The derivative of Cos(',ANGLE,') is : ' , -SIN(A
     $           NGLE)
         ELSE IF(PICK3 .EQ. 3)THEN
            WRITE(*,*)  'What is the angle you wish to calculate?'
            READ(*,*) ANGLE
            WRITE(*,*) 'The derivative of Tan(',ANGLE,') is : ' , 1/((CO
     $           S(ANGLE))**2)
         ELSE IF(PICK4 .EQ. 1)THEN
            WRITE(*,*)  'What is the log value you wish to calculate?'
            READ(*,*) VALUE
            WRITE(*,*) 'The derivative of Ln(',VALUE,') is : ' , 1/(VALU
     $           E)
         ELSE IF(PICK4 .EQ. 2)THEN
            WRITE(*,*)  'What is the log value you wish to calculate?'
            READ(*,*) VALUE
            WRITE(*,*) 'The derivative of Log(',VALUE,') is : ' ,1/(VALU
     $           E*LOG10(VALUE))
         ELSE IF(PICK4 .EQ. 3)THEN
            WRITE(*,*)  'What is the power you wish to calculate?'
            READ(*,*) VALUE
            WRITE(*,*) 'The derivative of Exp(',VALUE,') is : ' , EXP(VA
     $           LUE)
         ELSE
            WRITE(*,*) 'Incorrect input'
         ENDIF
         

      ELSE
         WRITE(*,*) '1: Trig Function  ',' 2: Log Function'
         READ(*,*) PICK5
         IF(PICK5 .EQ. 1)THEN
            WRITE(*,*) '1: Sin  ', ' 2: Cos  ', ' 3: Tan  '
            READ(*,*) PICK6
         ELSE
            WRITE(*,*) '1: Log base e   ', ' 2: Log base 10 ', ' 3: Exp'
            READ(*,*) PICK7
         ENDIF
         
         
         IF(PICK6 .EQ. 1)THEN
            WRITE(*,*)  'What is the angle you wish to calculate?'
            READ(*,*) ANGLE
            WRITE(*,*) 'Sin(',ANGLE,') is : ' , SIN(ANGLE)
         ELSE IF(PICK6 .EQ. 2)THEN
            WRITE(*,*)  'What is the angle you wish to calculate?'
            READ(*,*) ANGLE
            WRITE(*,*) 'Cos(',ANGLE,') is : ' , COS(ANGLE)
         ELSE IF(PICK6 .EQ. 3)THEN
            WRITE(*,*)  'What is the angle you wish to calculate?'
            READ(*,*) ANGLE
            WRITE(*,*) 'Tan(',ANGLE,') is : ' , TAN(ANGLE)
         ELSE IF(PICK6 .EQ. 1)THEN
            WRITE(*,*)  'What is the log value you wish to calculate?'
            READ(*,*) VALUE
            WRITE(*,*) 'Ln(',VALUE,') is : ' , LOG(VALUE)
         ELSE IF(PICK6 .EQ. 2)THEN
            WRITE(*,*)  'What is the log value you wish to calculate?'
            READ(*,*) VALUE
            WRITE(*,*) 'Log(',VALUE,') is : ' , LOG10(VALUE)
         ELSE IF(PICK6 .EQ. 3)THEN
            WRITE(*,*)  'What is the power you wish to calculate?'
            READ(*,*) VALUE
            WRITE(*,*) 'Exp(',VALUE,') is : ' , EXP(VALUE)
         ELSE
            WRITE(*,*) 'Incorrect input'
         ENDIF
      ENDIF
      END
      
