Article 51T10 Please help me with awk to output list of students, their grade as % and letter grade

Please help me with awk to output list of students, their grade as % and letter grade

by
jessmister04
from LinuxQuestions.org on (#51T10)
New to Unix and this is my first week of using awk. I attached the csv file and I am trying to output the NAME,PERCENT,LETTER for each student after adding up all their assignments scores and / possible points. Please help me if you can, I want to learn and understand the answer. The code I have started is below and I am confused as to if I need only 1 for loop or 2? Also, I am not too familiar with syntax and printing on UNIX. I only have taken one class in python.

BEGIN{

FS = ","

}
$4~/[0-9]/ {

EARN[$1$2]+=$4
POSSIBLE[$1$2]+=$5
STUDENTS[$1]++
CATEGORIES[$2]++
}
END{

# for(ASSIGNMENT in EARN) {
# print ASSIGNMENT,EARN[ASSIGNMENT]/POSSIBLE[ASSIGNMENT]
# }

for (STUDENT in STUDENTS) {
SURVEY=(EARN[$1"Survey"]/POSSIBLE[$1"Survey"])*0.05
HOMEWORK=(EARN[$1"Homework"]/POSSIBLE[$1"Homework"])*0.10
LAB=(EARN[$1"Lab"]/POSSIBLE[$1"Lab"])*0.30
QUIZ=(EARN[$1"Quiz"]/POSSIBLE[$1"Quiz"])*0.40
FINAL=(EARN[$1"Final"]/POSSIBLE[$1"Final"])*0.15
TOTAL=(SURVEY+HOMEWORK+LAB+QUIZ+FINAL)
LETTER="A"
if (TOTAL < 90) {
LETTER="B"
}
if (LETTER < 80) {
LETTER="C"
}
if (LETTER < 70) {
LETTER="D"
}
if (LETTER < 60) {
LETTER="F"
}

for(ASSIGNMENT in EARN) {
print ASSIGNMENT,EARN[ASSIGNMENT]/POSSIBLE[ASSIGNMENT],TOTAL[ASSIGNMENT],LETTER[ASSIGNMENT]

}
}
}latest?d=yIl2AUoC8zA latest?i=6Us5XQLA0yM:L8x29Hgg4sc:F7zBnMy latest?i=6Us5XQLA0yM:L8x29Hgg4sc:V_sGLiP latest?d=qj6IDK7rITs latest?i=6Us5XQLA0yM:L8x29Hgg4sc:gIN9vFw6Us5XQLA0yM
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments