Question
Programming Language: JAVA Need Help Trying To Calculate Student's GPA. I have pasted the three classes I have so far down below. ( Student ,
Programming Language: JAVA
Need Help Trying To Calculate Student's GPA. I have pasted the three classes I have so far down below. (Student,Classes,Grade)
Assignment: Generate a student report card that lists all classes, grades, and the grade point average for a semester.
Student.java
importjava.util.*;
public class Student {
private String firstName;
private String lastName;
private String IDnum;
private String gender;
private String gradeLevel;
public Student() {
firstName = " ";
lastName = " ";
IDnum = " ";
gender = " ";
gradeLevel = " ";
}
public Student(String ln, String fn, String ID, String gender, String gradeLevel) {
lastName = ln;
firstName = fn;
IDnum = ID;
this.gender = gender;
this.gradeLevel = gradeLevel;
}
/**gets the last name
* @return last name
*/
public String getln() {
returnlastName;
}
/**gets first name
* @return first name
*/
public String getfn() {
returnfirstName;
}
/**returns Student ID
* @return Student ID
*/
public String ID() {
return IDnum;
}
/**returns gender
* @return gender
*/
public String gender() {
return gender;
}
public String getGradeLevel(){
returngradeLevel;
}
public void setln(String ln) {
lastName=ln;
}
public void setfn(String fn) {
firstName=fn;
}
public void setID(String ID) {
IDnum=ID;
}
public void setGender(String gender) {
this.gender = gender;
}
public void setGradeLevel(String gradeLevel) {
this.gradeLevel = gradeLevel;
}
public double gradePointAverage() {
return 0;
}
/** it returns string of the different student details */
public String toString() {
return " Name: "+firstName + " " + lastName+" ID: "+IDnum +" Gender: "+gender +" Grade Level: "+ gradeLevel;
}
}
Classes.java
importjava.util.*;
public class Classes extends Student {
private String courseNumber;
private String courseName;
protected static String gradeLetter;
private String units;
public Classes() {
courseNumber = " ";
courseName = " ";
gradeLetter = " ";
units = " ";
}
public Classes(String cNumber, String cName, String gLetter, String units) {
courseNumber = cNumber;
courseName = cName;
gradeLetter = gLetter;
this.units = units;
}
/**Gets the Course Number
* @return course number
*/
public String getcourseNumber() {
returncourseNumber;
}
/**Gets Course Name
* @return course name
*/
public String getcourseName() {
returncourseName;
}
/**returns Grade Letter
* @return grade letter
*/
public String gradeLetter() {
returngradeLetter;
}
/**Gets Grade Letter
* @return grade letter
*/
public String getGradeLetter(){
returngradeLetter;
}
/**sets Last name with a new value
* @param ln Last name
*/
public void setcourseNumber(String courseNumber) {
this.courseNumber=courseNumber;
}
/**sets first name with a new value
* @param fn First name
*/
public void setcourseName(String courseName) {
this.courseName=courseName;
}
/**sets Id with a new value
* @param ID Employee ID
*/
public void setGradeLetter(String gradeLetter) {
this.gradeLetter=gradeLetter;
}
public void setUnits(String units) {
this.units = units;
}
/** it returns string of the different student details */
public String toString() {
return " Course Number: "+ "\tCourse Name: "+"\tUnits: " +"\tGrade: " + " " + courseNumber+"\t\t" +courseName+"\t\t" +units+"\t"+gradeLetter;
}
}
Grades.java
public class Grades extends Classes {
//static double gradePointAverage=0;
static Student student[]=new Student[1];
staticClasses classes[]=new Classes[4];
/** Main method which throws CloneNotSupportedException
* @param args
* @throws CloneNotSupportedException
*/
public static void main(String [] args)throws CloneNotSupportedException {
student[0]= new Student("Wilson", "Alison", "2420213", "F", "Senior");
classes[0]= new Classes("123", "Math", "A", "4");
classes[1]= new Classes("456", "English", "A", "3");
classes[2]= new Classes("789", "History", "A", "3");
classes[3]= new Classes("011", "Science", "A", "3");
for(inti=0;i<1;i++) {
System.out.println(student[i]);
}
for(int j=0;j<4;j++) {
System.out.println(classes[j]);
}
}
public double gradePointAverage() {
for(inti=6;i<9;) {
gradeLetter+=classes[j].gradePointAverage();
//String gra = " ";
double total = 0.0;
doubledecValue = 0.0;
if (gradeLetter.equals("A")) {
decValue = 4;
total += decValue;
} else if (gradeLetter.equals("B")) {
decValue = 3;
total += decValue;
} else if (gradeLetter.equals("C")) {
decValue = 2;
total += decValue;
} else if (gradeLetter.equals("D")) {
decValue = 1;
total += decValue;
} else if (gradeLetter.equals("F")) {
decValue = 0;
total += decValue;
System.out.println("GPA:"+ total);
}
returndecValue;
}
returngradeLetter;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started