Skip to content

Instantly share code, notes, and snippets.

@nogajun
Created November 16, 2012 15:01
Show Gist options
  • Save nogajun/4087974 to your computer and use it in GitHub Desktop.
Save nogajun/4087974 to your computer and use it in GitHub Desktop.
Himeji IT Study Vol.11 L-1 GP 2.GPA(Grade Point Average)
#!/bin/bash
N=$(head -n1 $1)
S=$(tail -n1 $1)
A=$(echo ${S}|tr -d [BCDF])
B=$(echo ${S}|tr -d [ACDF])
C=$(echo ${S}|tr -d [ABDF])
D=$(echo ${S}|tr -d [ABCF])
F=$(echo ${S}|tr -d [ABCD])
# echo $(((${#A}*4+${#B}*3+${#C}*2+${#D})/${N})) # sadly...
echo "scale=5;(${#A}*4+${#B}*3+${#C}*2+${#D})/${N}" | bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment