The gradeRecord class maintains student records for the registrar. Its attribute
ID: 3883900 • Letter: T
Question
Explanation / Answer
class StudObj {
private String studentID;
private int units;
private int gradepts;
public String getStudentID() {
return studentID;
}
public void setStudentID(String studentID) {
this.studentID = studentID;
}
public int getUnits() {
return units;
}
public void setUnits(int units) {
this.units = units;
}
public int getGradepts() {
return gradepts;
}
public void setGradepts(int gradepts) {
this.gradepts = gradepts;
}
public StudObj(String studentID, int units, int gradepts) {
super();
this.studentID = studentID;
this.units = units;
this.gradepts = gradepts;
}
}
public class GradeRecord {
StudObj student;
public GradeRecord(StudObj student) {
super();
this.student = student;
}
public double gpa() {
double d = student.getUnits();
double gpa = student.getGradepts()/d;
return gpa;
}
public void updateGradeInfo(int units, int gradepts){
this.student.setUnits(units);
this.student.setGradepts(gradepts);
}
public void writeGradeInfo(){
System.out.println("Student:" + this.student.getStudentID() +" Units:" + this.student.getUnits() + " GradePts:"+ this.student.getGradepts() + " GPA:" + this.gpa());
}
public static void main(String[] args) {
StudObj stud = new StudObj("783-29-4716", 100,345);
GradeRecord grdRcd = new GradeRecord(stud);
grdRcd.writeGradeInfo();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.