user1

03-18-2010, 06:48 PM

Hi

I need help on this code. Below is the specification of the program that I need to code.

Specification:

A building society decides to pay a bonus dependent upon the current balance of its saving accounts. There are currently 15 accounts with the following amount kept in them.

28763, 2845, 12567, 536, 59642

12658, 124632 , 4263, 61245, 563145,

7529, 15243, 452168, 12487,39487.

Each account will receive the following bonus payment for being within the specified ranges

0 - 5000 3%

5001 - 100k 5%

100k - 500k 7%

500k + 10%

You task is to create an array to hold the current balance, the percentage to be applied to a bonus, the bonus amount and the new balance including the bonus. The resultant array needs to be printed in an appropriate format

My attempt at the problem so far:

ry_calc

IMPLICIT NONE

INTEGER, DIMENSION(15) :: salary

REAL, DIMENSION(4) :: percentage

INTEGER, DIMENSION(15) :: new_salary

INTEGER, DIMENSION(15) :: bonus

INTEGER :: i=1

percentage = (/0.03,0.05,0.07,0.10/)

salary = (/28763,2845,12567,536,59642,12658,124632,4263,61245 ,563145,7529,15243,452168,12487,39487/)

DO i=1,15

IF ((salary(i)=>0) .AND. (salary(i)<=5000))THEN

bonus(i) = salary(i)*percentage(1)

ELSEIF ((salary(i)=>5001) .AND. (salary(i)<=100000))THEN

bonus(i) = salary(i)*percentage(2)

ELSEIF ((salary(i)=>100001) .AND. (salary(i)<=500000))THEN

bonus(i) = salary(i)*percentage(3)

ELSE

bonus(i) = salary(i)*percentage(4)

END IF

i = i + 1

END DO

!sumsal = SUM(salaries * increment(category))

PRINT '(5I8)', salary!'Cost of increase = ', sumsal

PRINT *

PRINT '(F7.2)', percentage

PRINT *

PRINT '(I8)', bonus

END PROGRAM salary_calc

any help would appreciated.

Thank you

User1.

I need help on this code. Below is the specification of the program that I need to code.

Specification:

A building society decides to pay a bonus dependent upon the current balance of its saving accounts. There are currently 15 accounts with the following amount kept in them.

28763, 2845, 12567, 536, 59642

12658, 124632 , 4263, 61245, 563145,

7529, 15243, 452168, 12487,39487.

Each account will receive the following bonus payment for being within the specified ranges

0 - 5000 3%

5001 - 100k 5%

100k - 500k 7%

500k + 10%

You task is to create an array to hold the current balance, the percentage to be applied to a bonus, the bonus amount and the new balance including the bonus. The resultant array needs to be printed in an appropriate format

My attempt at the problem so far:

ry_calc

IMPLICIT NONE

INTEGER, DIMENSION(15) :: salary

REAL, DIMENSION(4) :: percentage

INTEGER, DIMENSION(15) :: new_salary

INTEGER, DIMENSION(15) :: bonus

INTEGER :: i=1

percentage = (/0.03,0.05,0.07,0.10/)

salary = (/28763,2845,12567,536,59642,12658,124632,4263,61245 ,563145,7529,15243,452168,12487,39487/)

DO i=1,15

IF ((salary(i)=>0) .AND. (salary(i)<=5000))THEN

bonus(i) = salary(i)*percentage(1)

ELSEIF ((salary(i)=>5001) .AND. (salary(i)<=100000))THEN

bonus(i) = salary(i)*percentage(2)

ELSEIF ((salary(i)=>100001) .AND. (salary(i)<=500000))THEN

bonus(i) = salary(i)*percentage(3)

ELSE

bonus(i) = salary(i)*percentage(4)

END IF

i = i + 1

END DO

!sumsal = SUM(salaries * increment(category))

PRINT '(5I8)', salary!'Cost of increase = ', sumsal

PRINT *

PRINT '(F7.2)', percentage

PRINT *

PRINT '(I8)', bonus

END PROGRAM salary_calc

any help would appreciated.

Thank you

User1.