You are viewing a single comment's thread. Return to all comments →
**Tricky way ** * Uses an array to map numeric grade ranges to letter grades
awk ' BEGIN{ # Define grade mapping: index 0 -> "F", 1 -> "C", 2 -> "B", 3 -> "A" split("FCBA",grd,"") } { avg=($1+$2+$3)/3; #cond. --> fixBug: 40-59.9 result calc should be ind:2 , val:"C" # Special case: if average < 50, assign "FAIL" grade=(avg>=50)?grd[int(avg/20):"FAIL";] } {print $0 " : " grade} '
Seems like cookies are disabled on this browser, please enable them to open this website
'Awk' - 3
You are viewing a single comment's thread. Return to all comments →
**Tricky way ** * Uses an array to map numeric grade ranges to letter grades