Sunday, March 15, 2015

Employee Pay Calculation

Algorithm
Step 1 : Start
Step 2 : Read basic
Step 3 : If basic > 30000 then
hra is 5% of basic
da is 5% of basic
tax is 10% of basic
Step 3.1 : else if basic > 20000 then
hra is 4% of basic
da is 3% of basic
tax is 8% of basic
Step 3.2 : else
hra is 3% of basic
da is 2% of basic
tax is 5% of basic
Step 4 : Stop

Program (emppay.sh)
echo -n "Enter employee basic pay : "
read basic
if [ $basic -gt 30000 ]
then
hra=`expr 5 \* $basic / 100`
da=`expr 5 \* $basic / 100`
tax=`expr 10 \* $basic / 100`
elif [ $basic -gt 20000 ]
then
hra=`expr 4 \* $basic / 100`
da=`expr 3 \* $basic / 100`
tax=`expr 8 \* $basic / 100`
else

hra=`expr 3 \* $basic / 100`
da=`expr 2 \* $basic / 100`
tax=`expr 5 \* $basic / 100`
fi
gross=`expr $basic + $da + $hra`
netpay=`expr $gross - $tax`
echo "Gross Pay : $gross"
echo "Net Pay : $netpay"

Output
[vijai@localhost decision]$ sh emppay.sh
Enter employee basic pay : 12000
Gross Pay : 12600
Net Pay : 12000

No comments:

Post a Comment