5th Linux

PHOTO EMBED

Wed Nov 29 2023 07:48:29 GMT+0000 (Coordinated Universal Time)

Saved by @viinod07

Write a shell script that computes the gross salary of a employee according to the following 

rules: The basic salary is entered interactively through the key board.

iii. If basic salary is < 25000 then HRA =10% of the basic and DA =90% of the basic. 

iv. If basic salary is >=25000 then HRA =Rs500 and DA=98% of the basic.

Script:

echo enter the basic

read basic

if [ $basic -lt 15000 ]

then

hra=`echo "scale=2; $basic * 0.1" | bc`

da=`echo "scale=2; $basic * 0.9" | bc`

else

hra=500

da=`echo "scale=2; $basic * 0.98" | bc`

fi

gs=`echo "scale=2;$basic +$hra +$da" | bc`

echo " gross =" $gs

echo "hra =" $hra

echo "da =" $da

Output:

$ sh 8a.sh

enter the basic pay

1000

gross = 2000.0

hra = 100.0

da = 900.0

$ sh 8a.sh

enter the basic

20000

gross = 40100.00

hra = 500

da = 19600.00
content_copyCOPY