#!/bin/csh -f

# Compute "GPA" on a 10 point scale from a count of number of 10, 9,
# 8, ... grades given as $1, $2, $3, ....  Trailing 0's can be omitted
# from the argument list.

set w = 11
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
