--- capa/capa51/JavaTools/TScore.java 1999/11/29 19:56:28 1.2 +++ capa/capa51/JavaTools/TScore.java 2000/08/07 20:47:29 1.5 @@ -1,3 +1,27 @@ +/* old score extrapolator widget + Copyright (C) 1992-2000 Michigan State University + + The CAPA system is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The CAPA system is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with the CAPA system; see the file COPYING. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + As a special exception, you have permission to link this program + with the TtH/TtM library and distribute executables, as long as you + follow the requirements of the GNU GPL in regard to all of the + software in the executable aside from TtH/TtM. +*/ + import java.applet.*; import java.awt.*; import java.lang.*; @@ -111,7 +135,7 @@ public void init() { // if epc 1 is not given, use exam 1 as epc 1 // if exam 2 is not given, use exam 1 to extrapolate // if exam 3 is not given, use exam 2 to extrapolate - // + // I am lying, I only use the homework score float exam_sum = (float)0.0; for(idx=0;idx max) {f=max;} } catch (java.lang.NumberFormatException e) { f = 0.0; } @@ -388,7 +414,8 @@ class ExpPanel extends Panel } void recalcSumm(int tf) { float my_r = (float) tf / (float)100.0; - int tmp_i= (int)(10000*(ss+(rr*ff*my_r/cc))/(float)(ff*(1.0+rr/cc))); + int tmp_i= (int)(10000*(ss+((float)rr*ff*my_r/(cc+rr)))/(float)(ff*(1.0+(float)rr/(cc+rr)))); + //System.out.print("ss ="+ss+":rr="+rr+":ff="+ff+":my_r="+my_r+":cc="+cc+":tmp_i="+((float)tmp_i/10000.0)+"\n"); float sum = (float)tmp_i / (float)100.0; sumL.setText(sum + "%"); controller.recalcTermScore(); @@ -459,7 +486,11 @@ class ExmPanel extends Panel if( exam_x == 0 ) { // exam not extrapolated - exam_ratio = (float)s_ex / (float)f_ex; + if ((float)f_ex < 0.00000001) { + exam_ratio = (float) 0.0; + } else { + exam_ratio = (float)s_ex / (float)f_ex; + } tmp_i = (int) (10000 * exam_ratio ); float percent = (float)tmp_i / (float)100.0; String cs = " " + a + "/" + b + " = " + percent + " %"; @@ -536,7 +567,12 @@ class ExmPanel extends Panel gridbag.setConstraints(eL, c); add(eL); if( epc_x == 0 ) { - float ratio = (float) ( s_pc / f_pc); + float ratio; + if ((float)f_pc < 0.00000001) { + ratio = (float) 0.0; + } else { + ratio = (float) ( s_pc / f_pc); + } tmp_i = (int) (10000 * ratio ); float percent = (float)tmp_i / (float)100.0; String cs = " " + s_pc + "/" + f_pc + " = " + percent + " %";