SHARE
TWEET

Untitled

a guest Oct 24th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BEGIN {
  2.     FS=",";
  3.     printf("Name       Average\n")
  4.     printf("----       -------\n")
  5.     numPeople=0
  6. }
  7.  
  8. {
  9.     if (1<NR)
  10.     {
  11.        printf("%-10s %7.2f\n",$1,($3+$4+$5)/3.0)
  12.        numPeople++
  13.        sumTest[0]=sumTest[0]+$3
  14.        sumTest[1]=sumTest[1]+$4
  15.        sumTest[2]=sumTest[2]+$5
  16.        if ("Red"==$2) sumTeam["Red"]=sumTeam["Red"]+$3+$4+$5
  17.        if ("Blue"==$2) sumTeam["Blue"]=sumTeam["Blue"]+$3+$4+$5
  18.        if ("Green"==$2) sumTeam["Green"]=sum["Green"]+$3+$4+$5
  19.     }
  20. }
  21.  
  22. END {
  23.     printf("------------------\n")
  24.     printf("Average for Test 1: %f\n",sumTest[0]/numPeople)
  25.     printf("Average for Test 2: %f\n",sumTest[1]/numPeople)
  26.     printf("Average for Test 3: %f\n",sumTest[2]/numPeople)
  27.     printf("------------------\n")
  28.     printf("Average for Red Team: %f\n",sumTeam["Red"]/9.0)
  29.     printf("Average for Green Team: %f\n",sumTeam["Green"]/9.0)
  30.     printf("Average for Blue Team: %f\n",sumTeam["Blue"]/6.0)
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top