(takes input in the form of one grade, lower case, per line.)%g=("a"=>4, "b"=>3, "c"=> 2, "d"=>1, "f"=>0, "+"=> 1/3 , "-"=> -1/3); while (<>){ chomp; next unless m/^([abcdf])([+-])?$/; $n+=1; $t+= $g{$1}; m/(a\+|f-)/ or $t+=$g{$2};} print($t/$n,"\n");
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |