PROGRAM Areas
   IMPLICIT NONE

   REAL    :: Side, Height, Radius, Area, Base 
   REAL, PARAMETER :: Pi = 3.14159 
   INTEGER :: Choice


   WRITE(*,*) 'Which shape do you want to calculate the area for?'
   WRITE(*,*) 'Enter 1 for circle'
   WRITE(*,*) 'Enter 2 for rectangle'
   WRITE(*,*) 'Enter 3 for triangle'
   READ(*,*) Choice
   
 
   IF ( Choice == 1 ) THEN
      WRITE(*,*) 'Enter the radius of the circle'
      READ(*,*) Radius
      IF ( Radius >= 0 ) THEN
          Area = Pi * Radius ** 2
          WRITE(*,*) 'The area of a circle with '
          WRITE(*,*) 'radius of ',Radius,' is ', Area
      ELSE
         WRITE(*,*) 'The radius you gave was negative, try again'
      END IF
   ELSE IF ( Choice == 2 ) THEN
      WRITE(*,*) 'Enter the lengths of the two sides of'
      WRITE(*,*) 'rectangle:'
      READ(*,*) Side, Height
      IF ( Side >= 0 .AND. Height >= 0 ) THEN
         Area = Height * Side
         WRITE(*,*) 'The area of a rectangle with a width of ', Side
         WRITE(*,*) 'and the height of ', Height 
         WRITE(*,*) 'is equal to  ', Area 
      ELSE
         WRITE(*,*) 'One of the lengths you gave, was negative, try again'
      END IF
   ELSE IF ( Choice == 3 ) THEN
      WRITE(*,*) 'Enter the base and Height of the triangle: '
      READ(*,*) Base, Height
      IF ( Base >= 0 .AND. Height >= 0 ) THEN
         Area = (Height * Base) / 2.0    
         WRITE(*,*) 'The area of a triangle with a base of ', Base
         WRITE(*,*) 'and the height of ', Height 
         WRITE(*,*) 'is equal to  ', Area 
      ELSE    
         WRITE(*,*) 'One of the lengths you gave, was negative, try again'
      END IF
   ELSE 
      WRITE(*,*) 'You Gave a wrong Choice, try again'
   END IF
END PROGRAM Areas
