you really need to be absolute when you enter rules based things like this...
what happens if he has only worked 11 months?
i will asume he gets nothing!
and are these a lotted days pay multiplied by the years of service?
i wil asume yes!
the simplest solution is to draw out the alottment as a function of years of service
Code:
Rules is if the employee has completed between 1 - 2 years of service he is entitled to 7 days of Basic salary
y(1)=7
y(2)=7
If the employee has completed between 2 - 4 years of service he is entitled
to 14 days of Basic salary
y(3)=14
y(4)=14
If the employeed has completed 5 years of service he is entitled to 21 days
of Basic salary
y(5)=21
If completed more than 5 years he is entitled to 30 days of Basic salary,But
here the catch is for first 5 years he will get 21 days and balance years will
be calculated in 30 days basic pay
y(6)=30
y(7)=30
..
..
y(n)=30
if you set up such an array you can simpy sum the values of the arrays
you could precalculate the vales and fill the arrays so that a given years service is y(given years)=98 days or whatever!
its a do all the arithmatic up front approach!
Code:
y(1)=7
y(2)=14
y(3)=28
y(4)=42
y(5)=63
y(6)=93
y(7)=123
..
..
y(n)=y(5)+((n-5)*30)
here to help ( i can always write the formula out if you really want y(n)=...from the very start y(0))