The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #12 (permalink)  
Old 07-02-2009
dsptl dsptl is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 9
Quote:
Originally Posted by vidyadhar85 View Post
This is what you looking for..

Code:
BEGIN{ print "Name   Test1   Test2   Test3   Average   Grade"}
{avg=($2+$3+$4)/3;
                if (avg >= 90 && avg < 100) grade="A"
                else if (avg >= 80 && avg < 89) grade="B"
                else if (avg >= 70 && avg < 79) grade="C"
                else if (avg >= 60 && avg <69) grade="D"
                else grade="F"
printf("%-8s%-8d%-8d%-8d%-8d%-8s\n",$1,$2,$3,$4,avg,grade)}
END{
print "Average"}
no i hv this

i am looking for the last line in output which is average of each test

here: