Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROGRAM tut5
- ! Program that computes the bonus paid to several employees given their annual sales
- IMPLICIT NONE
- REAL :: Sum, average
- INTEGER :: EmployeeNo
- INTEGER, PARAMETER :: EmployeeTotal = 11
- INTEGER, DIMENSION ( EmployeeTotal ) :: identity, sales, BonusPercent
- REAL, DIMENSION ( EmployeeTotal ) :: paid
- OPEN ( 10, FILE = "input.txt" )
- OPEN ( 30, FILE = "output.txt" )
- EmployeeNo = 1
- DO
- READ ( 10, * ) identity ( EmployeeNo ), sales ( EmployeeNo )
- IF ( EmployeeNo == EmployeeTotal ) EXIT
- EmployeeNo = EmployeeNo + 1
- END DO
- WRITE ( 30, '(1x, a68)' ) "YEARLY BONUS REPORT FOR MUHIBBAH ENGINEERING"
- WRITE ( 30, '(1x, a68, /)' ) "--------------------------------------------"
- WRITE ( 30, '(1x, a15, a21, a21, a15)' ) "Salesperson ID", "Yearly Sales", "Bonus Percentage", "Bonus Paid"
- WRITE ( 30, '(1x, a15, a21, a21, a15)' ) "--------------", "------------", "----------------", "----------"
- WRITE ( 30, '(1x, a30, a17, a20, /)' ) "(RM)", "(%)", "(RM)"
- PRINT '(1x, a68)', "YEARLY BONUS REPORT FOR MUHIBBAH ENGINEERING"
- PRINT '(1x, a68, /)', "--------------------------------------------"
- PRINT '(1x, a15, a21, a21, a15)', "Salesperson ID", "Yearly Sales", "Bonus Percentage", "Bonus Paid"
- PRINT '(1x, a15, a21, a21, a15)', "--------------", "------------", "----------------", "----------"
- PRINT '(1x, a30, a17, a20, /)', "(RM)", "(%)", "(RM)"
- CALL BonusSchedule ( EmployeeTotal, sales, BonusPercent, paid )
- EmployeeNo = 1
- Sum = 0.0
- DO
- WRITE ( 30, '(1x, i10, i22, i15.2, f23.2)' ) identity ( EmployeeNo ), sales ( EmployeeNo ), &
- BonusPercent ( EmployeeNo ), paid ( EmployeeNo )
- PRINT '(1x, i10, i22, i15.2, f23.2)', identity ( EmployeeNo ), sales ( EmployeeNo ), &
- BonusPercent ( EmployeeNo ), paid ( EmployeeNo )
- Sum = Sum + sales ( EmployeeNo )
- IF ( EmployeeNo == EmployeeTotal ) EXIT
- EmployeeNo = EmployeeNo + 1
- END DO
- average = Sum / EmployeeTotal
- WRITE ( 30, *)
- WRITE ( 30, '(1x, a25, f10.2, /)' ) "average yearly sales = RM", average
- PRINT *
- PRINT '(1x, a25, f10.2, /)', "average yearly sales = RM", average
- CONTAINS
- SUBROUTINE BonusSchedule ( total, Sales, Percent, paid )
- INTEGER :: I, Start = 1
- INTEGER, INTENT ( IN ) :: total
- INTEGER, DIMENSION ( total ), INTENT ( IN ) :: Sales
- INTEGER, DIMENSION ( total ), INTENT ( OUT ) :: Percent
- REAL, DIMENSION ( total ), INTENT ( OUT ) :: paid
- DO I = Start, total
- IF ( Sales ( I ) < 20000 ) THEN
- Percent ( I ) = 0
- ELSE IF ( Sales ( I ) < 100000 ) THEN
- Percent ( I ) = 2
- ELSE IF ( Sales ( I ) <= 200000 ) THEN
- Percent ( I ) = 3
- ELSE
- Percent ( I ) = 5
- END IF
- paid ( I ) = Percent ( I ) * Sales ( I ) / 100.0
- END DO
- END SUBROUTINE BonusSchedule
- END PROGRAM tut5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement