All pastes #452356 Raw Edit

Untitled

public java v1 · immutable
·published 2007-04-22 06:27 UTC
rendered paste body
    public GPAResultPair getGPA()    {        double totalCredit = 0;        double totalGrade = 0;       double curGrade = 0;          for(int i=0; i < transcriptArray.length; i++)            {                for(int j=0; j < transcriptArray[i].getGradeEntries().length; j++)                    {                        GradeEntry grd = transcriptArray[i].getGradeEntries()[j];                         if(grd.getCourseGrade() != "-")						{                            totalCredit = totalCredit + grd.getCourseCredit();	                        if(grd.getCourseGrade().charAt(0)=='A')	                            curGrade = 4;	                        if(grd.getCourseGrade().charAt(0)=='B')	                            curGrade = 3;	                        if(grd.getCourseGrade().charAt(0)=='C')	                            curGrade = 2;	                        if(grd.getCourseGrade().charAt(0)=='D')	                            curGrade = 1;	                        if(grd.getCourseGrade().charAt(0)=='F')	                            curGrade = 0;	 	                        if(grd.getCourseGrade().length() == 2)	                            {	                                if(grd.getCourseGrade().charAt(1)=='-')	                                    curGrade -= .3;	                                else if (grd.getCourseGrade().charAt(1)=='+')	                                    curGrade += .3;	                            }	 	                        totalGrade += curGrade*grd.getCourseCredit();						}                    }            }         GPAResultPair gpa = new GPAResultPair();               //all pending        if(totalCredit <= 0)            {                gpa.isLegitimateGPA = false;                gpa.GPA = 0;            }        else            {                gpa.isLegitimateGPA = true;                gpa.GPA = totalGrade/totalCredit;            }                    return gpa;     }