<%@ page language="java" %> <% // Original from Adam J Boltz // Greatly modified by Jeff Offutt // November 2009, homework 6 in SWE 642 // // This version has all computation in the JSP. // // If the parameter courseCount is 0, no other data is being sent, // so draw one blank row. // A JS function adds additional rows. // If courseCount is not 0, then draw the first row, // then perform the calculations, summarize the data, and compute GPA. // // Parameters: // courseNameX // courseCreditX // courseGradeX // One for each row, where 'X' is the row number. // How many courses are sent. // This is a hidden form field that is updated by JS when // a new course is added. Integer count = 0; String courseCount = request.getParameter ("courseCount"); if (courseCount != null) { // Convert to integer if not null. count = Integer.parseInt (request.getParameter ("courseCount")); } int defaultHours = 3; // Constant to be easy to change. %> Grade Calculator
George Mason University Grade Calculator
Calculates the current GPA and the minimum GPA needed in the remaining classes
Designed for MS students
Fall 2009

Base requirements for an MS degree at GMU

  • GPA must be at least 3.0
  • 10 courses
  • No more than 2 Cs allowed

Grading Chart
A+AA- B+BB- CF
4.04.03.7 3.333.02.67 2.00.0
Course Name Credit Hours Grade
A+   A   A-   B+   B   B-   C   F
Additional course      


<% // If count is 0, then we have no submission. // Print the blank form (above) and no response. if (count > 0) { %> Classes taken: <% Float totalHours = 0f; Float qualityPts = 0f; for (int i=1; i <= count; i++) { // Each row is a base name concatenated with an integer String name = request.getParameter ("courseName" + i); String hours = request.getParameter ("courseCredit" + i); String grade = request.getParameter ("courseGrade" + i); Float hoursFt = Float.parseFloat (hours); totalHours += hoursFt; if (grade.equals ("A+") || grade.equals ("A")) { qualityPts += 4f * hoursFt; } else if (grade.equals ("A-")) { qualityPts += 3.67f * hoursFt; } else if (grade.equals ("B+")) { qualityPts += 3.33f * hoursFt; } else if (grade.equals ("B")) { qualityPts += 3f * hoursFt; } else if (grade.equals ("B-")) { qualityPts += 2.67f * hoursFt; } else if (grade.equals ("C")) { qualityPts += 2f * hoursFt; } %> <% } %>
Course Name Credit Hours Grade
<%= name %> <%= hours %> <%= grade %>

Current GPA: <%= qualityPts/totalHours %>

<% // If not enough hours, what is needed to graduate? if (totalHours >= 30) { %> You have <%= totalHours %> hours, which is enough to graduate with an MS degree. <% if (qualityPts/totalHours < 3.0f) { %> However, you do not have the minimum GPA of 3.0. <% } } else { Float neededGPA = (90f - qualityPts) / (30 - totalHours); %> You need <%= 30 - totalHours %> more hours to graduate. You must average a GPA of <%= neededGPA %> in those classes to graduate with a GPA of 3.0 or above. You can also only apply two grades of C to your MS degree. <% } %> <% } %>


Implementation by Adam Boltz, modified by Jeff Offutt
© 2009, all rights reserved.
Last update: 05-November-2009