Class GradeCalculator

java.lang.Object
  extended by GradeCalculator

public class GradeCalculator
extends java.lang.Object

Class that calculates the average of a collection of grades, possibly dropping the lowest grade.

Version:
2/14/2010
Author:
Dave Reed

Constructor Summary
GradeCalculator()
          Constructor for objects of class GradeCalculator.
 
Method Summary
 void enterGrade(int nextGrade)
          Enters a grade and updates the totals accordingly.
 double getAverage()
          Determines the average of the grades entered so far.
 java.lang.String getLetterGrade()
          Determines the letter grade earned by the current grades entered.
 int getLowestGrade()
          Accessor method for the lowest grade.
 int getNumberOfGrades()
          Accessor method for the number of grades.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GradeCalculator

public GradeCalculator()
Constructor for objects of class GradeCalculator.

Method Detail

enterGrade

public void enterGrade(int nextGrade)
Enters a grade and updates the totals accordingly.

Parameters:
nextGrade - the grade to be entered (it is assumed that grades are in the range 0 to 100)

getAverage

public double getAverage()
Determines the average of the grades entered so far.

Returns:
the average of the grades (if no grades entered, returns 0.0; if at least 5 grades, then the lowest grade is dropped)

getLetterGrade

public java.lang.String getLetterGrade()
Determines the letter grade earned by the current grades entered.

Returns:
the letter grade ("A" for 90+, "B" for 80+, etc.)

getLowestGrade

public int getLowestGrade()
Accessor method for the lowest grade.

Returns:
the lowest grade entered so far

getNumberOfGrades

public int getNumberOfGrades()
Accessor method for the number of grades.

Returns:
the number of grades entered so far