6/19/2009

Openoffice calc function script giving a grade from a rank

The following function returns a degree (e.g., A+ or A or ... etc) from a rank data

Function getdegree(V)
'--------------------------------------------------
' Parameters must be set according to each class
'--------------------------------------------------

total = 31 ' total student number
Ap_percent = 15 * 0.01 ' percentage of A+ degree= 15%
A_percent = 30 * 0.01 ' accumulated percentage 0f A degree
Bp_percent = 45 * 0.01
B_percent = 60 * 0.01
Cp_percent = 85 * 0.01
C_percent = 100 * 0.01
Dp_percent = 0 * 0.01
D_percent = 0 * 0.01

'---------------------------------------------------

Ap = int(total * Ap_percent)
A = int(total * A_percent)
Bp = int(total * Bp_percent)
B = int(total * B_percent)
Cp = int(total * Cp_percent)
C = int(total * C_percent)
Dp = int(total * Dp_percent)
D = int(total * D_percent)



select case V
case 1 to Ap
getdegree = "A+"
case Ap to A
getdegree = "A"
case A to Bp
getdegree = "B+"
case Bp to B
getdegree = "B"
case B to Cp
getdegree = "C+"
case Cp to C
getdegree = "C"
case C to Dp
getdegree = "D+"
case Dp to D
getdegree = "D"
case else
getdegree = "F"
end select

End Function

댓글 없음: