averages for FCFS,SJF,RR,HPF works correctly. the avgwaiting() you did, you forgot to subtract by arrival.