I am doing project, that deals with an array and I was having trouble with one of the methods called calcuateGPA. The method goes through an array of courses and makes the appropriate calculation. Here is the code and method below :
/** @author CCochran */
/** @version Java Version 6 Update 30 */
/** Creates Transcript class which stores information about classes a student has taken */
public class Transcript
{
/** Instance filed for gpa */
private double gpa;
/** Instance field for courses variable */
private Course[] courses;
/** Instance field for studentid variable */
private int studentID;
/** Instance field for courseid */
private String courseID;
/** Instance field for numbergrade */
private double numbergrade;
/** Instance field for lettergrade */
private String lettergrade;
/** Instance field for studentname variable */
private String studentName;
/** Instance field for count variable */
private int count;
/** Parameterized constructor
@param studentID studentname */
public Transcript(int studentID, String studentName)
{
this.studentID = studentID;
this.studentName = studentName;
}
/** Method that adds a course to the transcript
@param courseID lettergrade */
public void addCourse(String courseID, String lettergrade)
{
Course[] courses = new Course[10];
courseID = " ";
lettergrade = " ";
}
/** Method that updates the course in the transcript
@param courseID lettergrade */
public void updateCourse(String courseID, String lettergrade)
{
int count = 10;
Course[] courses = new Course[10] ;
this.courseID = courseID;
this.lettergrade = lettergrade;
}
/** Method that calculates the gpa */
private void calculateGPA()
{
Courses[] courses = new Course[10];
}
/** Method that returns the gpa of the student
@return the gpa */
public double getGPA()
{
return gpa;
}
/** Method that gets and returns the course information in a string for the student
@return course */
public String getCourse()
{
return(courseID + " " + lettergrade + " " + numbergrade);
}
/** Method that returns a string
@return string */
public String toString()
{
return(studentID + "\n"+ studentName + " " + "\n" + gpa +"\n"+ courseID + " " + lettergrade + " " + numbergrade);
}
}