Java Reference
In-Depth Information
public int
getHoursEnrolled()
{
int
totalCredits = 0;
for
(
int
i = 0; i < numberOfCourses; i++)
totalCredits += coursesEnrolled[i].getCredits();
return
totalCredits;
}
If a student has not paid the tuition, the method
billingAmount
calculates and
returns the amount due, based on the number of credit hours enrolled. The definition
of this method is:
public double
billingAmount(
double
tuitionRate)
{
return
tuitionRate * getHoursEnrolled();
}
We now discuss the method
getGpa
. This method calculates a student's GPA. To
find the GPA, we find the equivalent points for each grade, add the points, and then
divide the sum by the total credit hours the student is taking. The definition of this
method is:
public double
getGpa()
{
double
sum = 0.0;
for
(
int
i = 0; i < numberOfCourses; i++)
{
switch
(courseGrades[i])
{
case
'A':
sum += coursesEnrolled[i].getCredits() * 4;
break
;
case
'B':
sum += coursesEnrolled[i].getCredits() * 3;
break
;
case
'C':
sum += coursesEnrolled[i].getCredits() * 2;
break
;
case
'D':
sum += coursesEnrolled[i].getCredits() * 1;
break
;
case
'F':
break
;
Search WWH ::
Custom Search