'Shell Script to calculate bonus according to salary in Linux Shell Scripting
[If Salary >= 5000 then bonus = 5% of Salary
Print Bonus
If Salary < 5000 then bonus = 3% of Salary
Print Bonus
If Salary <= 10000 and >=8000 then bonus = 7% of salary
print Bonus]
Code:
echo "Enter a Salary"
read num
if [ $num -gt 5000 ]
then
percentage=$((num*5/100))
echo "The 5 Percent of Salary is: $percentage"
elif [ $num -lt 5000 ]
then
percentage=$((num*3/100))
echo "The 3 Percent of Salary is $percentage"
else
echo "The 7 Percent of Salary is $percentage*7/100"
fi
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
