Thursday 21 May 2015

Write an awk script to compute gross salary of an employee accordingly to rule given below. VTU MCA UNIX LAB11b





 If basic salary is < 10000 then HRA=15% of basic & DA=45% of basic
If basic salary is >=10000 then HRA=20% of basic & DA=50% of basic.


BEGIN{
printf("\nEmp No \t Emp Name \t Basic \t Gross")
printf("\n.................................................")
}
{
    if($3<10000)
    {
        hra=(15/100)*$3
        da=(45/100)*$3
    }
    else
    {
        hra=(20/100)*$3
        da=(50/100)*$3
       
    }
    gross=$3+hra+da
    printf("\n %d\t%s\t%f\t%f",$1,$2,$3,gross)
}
END{
    printf("\n...........................................")
}

No comments:

Post a Comment