#!/bin/csh -f

# Compute GPA on a four point scale from a count of number of A, B, C,
# D, and F grades given as $1, $2, $3, $4, and $5.  Trailing 0's can
# be omitted from the argument list.

set w = 5
set s = 0
set n = 0

foreach i ($*)
  @ w = $w - 1
  @ s = $s + $i * $w
  @ n = $n + $i
end

@ a = ($s * 100) / $n

@ i = $a / 100
@ f = $a
if ($a>99) set f = `echo $a | cut -c2,3`

echo $i.$f
