#!/bin/bash answer=yes totalsalary=0 totalit=0 totalhr=0 totalmark=0 countTot=0 countit=0 counthr=0 countmark=0 max=-99999999 min=999999999 avgtot=0 avgit=0 avghr=0 avgmark=0 while [ "$answer" = "yes" ] do clear read -p "Please enter employee first name : " fn read -p "Please enter employee last name : " lan read -p "Please enter salary : " sal while [ $sal -lt 0 ] do echo "value must be positive" read -p "Please enter salary : " sal done read -p "Please enter department name IT/HR/MARK: " dep echo $dep while [ "$dep" != "it" ] && [ "$dep" != "hr" ] && [ "$dep" != "mark" ] && [ "$dep" != "IT" ] && [ "$dep" != "HR" ] && [ "$dep" != "MARK" ] do echo "value must be IT, HR, or Mark" read -p "Please enter department name IT/HR/MARK: " dep done totalsalary=$(echo "scale=2; $totalsalary+$sal" | bc -l) let countTot=countTot+1 if [ $sal -lt $min ] then min=$sal fi if [ $sal -gt $max ] then max=$sal fi if [ $dep = "IT" ] || [ $dep = "it" ] then totalit=$(echo "scale=2; $totalit+$sal" | bc -l) let countit=countit+1 fi if [ $dep = "HR" ] || [ $dep = "hr" ] then totalhr=$(echo "scale=2; $totalhr+$sal" | bc -l) let counthr=counthr+1 fi if [ $dep = "MARK" ] || [ $dep = "mark" ] then totalmark=$(echo "scale=2; $totalmark+$sal" | bc -l) let countmark=countmark+1 fi #echo "the result is : $totalsalary $countTot $totalit $countit $totalhr $counthr $totalmark $countmark " read -p "do you want to play again yes/no " answer done avgtot=$(echo "scale=2; $totalsalary/$countTot" | bc -l) echo "The Total Average salary is $avgtot " echo "The max salary is $max " echo "The Min salary is $min" if [ $countit -ne 0 ] then avgit=$(echo "scale=2; $totalit/$countit" | bc -l) echo "The IT Average salary is $avgit " else echo "The IT Average salary is not Available" fi if [ $counthr -ne 0 ] then avghr=$(echo "scale=2; $totalhr/$counthr" | bc -l) echo "The HR Average salary is $avghr " else echo "The HR Average salary is not Available" fi if [ $countmark -ne 0 ] then avgmark=$(echo "scale=2; $totalmark/$countmark" | bc -l) echo "The Marketing Average salary is $avgmark " else echo "The Marketing Average salary is not Available" fi