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
Rules is if the employee has completed between 1 - 2 years of service he is entitled to 7 days of Basic salary
If the employee has completed between 2 - 4 years of service he is entitled
to 14 days of Basic salary
If the employeed has completed 5 years of service he is entitled to 21 days
of Basic salary
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
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!
here to help ( i can always write the formula out if you really want y(n)=...from the very start y(0))