PROGRAM Pay_Calculation
!-----------------------------------------------------------------------
! Program to calculate weekly pay for an employee.  Salaried employees
! receive 1/52 of their annual salaries.  Other employees are paid on
! an hourly basis with overtime hours paid at 1.5 times the regular
! hourly rate.  Identifiers used are:
!     EmployeeType : employee type (S or H)
!     Salary       : annual salary (for salaried employees)
!     HoursWorked,   hours worked and
!     HourlyRate   :   hourly rate (for hourly employees)
!     Multiplier   : multiplier for overtime pay
!     Pay          : employee's pay
!
! Input:  EmployeeType
!         Salary for salaried employees, or
!         HoursWorked and HourlyRate for hourly employees*
! Output: Pay
!-----------------------------------------------------------------------
  IMPLICIT NONE
  CHARACTER(1) :: EmployeeType
  REAL :: Salary, HoursWorked, HourlyRate, Pay
  REAL, PARAMETER :: Multiplier = 1.5

  ! Get employee type (S or H)
  PRINT *, "Enter the type of employee (S or H):"
  READ *, EmployeeType

  ! Select appropriate method of calculating pay:
  IF (EmployeeType == "S") THEN              ! Salaried employee
     PRINT *, "Enter employee's annual salary:"
     READ *, Salary
     Pay = Salary / 52

  ELSE                                       ! Hourly employee
     PRINT *, "Enter hours worked and hourly rate:"
     READ *, HoursWorked, HourlyRate
     IF (HoursWorked > 40.0) THEN
        Pay = 40.0 * HourlyRate &
            + Multiplier * HourlyRate * (HoursWorked - 40.0)
     ELSE
        Pay = HoursWorked * HourlyRate
     END IF
  END IF

  ! Display employee's pay
  PRINT *, "Employee's pay is", Pay
  STOP
END PROGRAM Pay_Calculation
