Guest User

Untitled

a guest
Jul 6th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 2.18 KB | None | 0 0
  1. BEGIN{ FS=":"
  2.       print  "                              ***FIRST QUARTERLY REPORTS***                   "
  3.       print  "                            ***CAMPAIGN 2000 CONTRIBUTIONS***                   "
  4.       print  "-------------------------------------------------------------------------------------"
  5.       print  "Name                 Phone              Jan  |   Feb  |  Mar  |       Total Donated"
  6.       print  "-------------------------------------------------------------------------------------"
  7.       min = 9999;
  8.       max = 0;
  9.       }
  10. {
  11.   for (i = 3; i < 6; i++)
  12.   {
  13.     if ($i < min)
  14.        min =  $i
  15.     if ($i > max)
  16.        max = $i
  17.   }
  18.  
  19.   totalCont = $3+$4+$5;
  20.   total =  total+totalCont;
  21.   average = (total / 12);
  22.   highestTotal;
  23.   highestNameLong;
  24.   highestNameShort;
  25.  
  26.   { if (totalCont > 500)
  27.     printf("    %-s--%s \n",
  28.       $1, $2 ) | "sort -k 2" }
  29.  
  30.   {split($1,highName," ")}
  31.   if ($3+$4+$5 > highestTotal)
  32.   {  highestTotal = $3+$4+$5
  33.      highestNameLong = $1
  34.      highestNameShort = highName[1]
  35.   }
  36.  
  37.   printf ("%-20s %-17s %-.2f\t%-.2f \t%-.2f \t\t%-.2f \n", $1, $2, $3, $4, $5, totalCont)
  38. }
  39.  END{print  "--------------------------------------------------------------------------------------"
  40.      print  "                                        SUMMARY                                "
  41.      print  "--------------------------------------------------------------------------------------"
  42.  
  43.      printf ("The campaign received a total of $%.2f for this quarter.\n", total)
  44.      printf ("The average donation for the 12 contributors was $%.2f.\n", average)
  45.      printf ("The highest contribution was $%.2f.\n", max)
  46.      printf ("The lowest contribution was $%.2f.\n", min)
  47.      printf ("The highest total contribution was $%.2f made by %s\n", highestTotal, highestNameLong)
  48.      print  "                            ***THANKS "highestNameShort"***"
  49.      print  "The following people donated over $500 to the campaign."
  50.      print  "They are eligible for the quarterly drawing!!"
  51.      print  "Listed are their names (sorted by last names) and phone numbers:"
  52.      close("sort -k 2");
  53.      printf  ("       Thanks to all of you for your continued support!!\n")
Add Comment
Please, Sign In to add comment