CSC 221: Computer Programming I         Spring 2010

HW 3: Class Design and Implementation

For this assignment, you will design and implement a class for calculating the average of a collection of grades. Your GradeCalculator class should have the following methods:

void enterGrade(int grade)
Takes a grade as input and updates the totals accordingly. You may assume that grades are in the range 0 to 100.
int getNumberOfGrades()
Accessor method that returns the number of grades entered so far.
int getLowestGrade()
Accessor method that returns the lowest grade entered so far.
double getAverage()
Determines the average of the grades entered so far. For example, if grades 90 and 85 have been entered, then the method should return 87.5. If at least 5 grades have been entered, then the lowest grade entered so far should be dropped when calculating the average. For example, if grades 90, 80, 70, 75, and 90 have been entered, then the method should return 85.0 (since that is the average of the four remaining grades after 70 is dropped). If no grades have been entered, then the method should return 0.0.
String getLetterGrade()
Determines the letter grade based on the average computed by getAverage. A grade of 90+ earns an "A", 80+ earns a "B", 70+ earns a "C", 60+ earns a "D", and anything less than 60 earns an "F".

Your code should demonstrate good style. The class should have a comment block that describes its purpose, as well as your name (under @author) and date (under @version). Similarly, each method should have comment block that describe its behavior as well as any parameters (under @param) and return values (under @return). Sample comments can be found on the GradeCalculator javadoc page. Statements should be consistently indented to highlight structure, and all method/variable names should be meaningful.


Submit your GradeCalculator class via the digital dropbox on BlueLine.