Question: Homework help! Consider the Student class definition: public class Student { private String name; private double gpa; private String major; public Student(String name, double gpa,
Homework help!
Consider the Student class definition:
public class Student {
private String name;
private double gpa;
private String major;
public Student(String name, double gpa, String major){
this.name = name;
this.gpa=gpa;
this.major=major;
}
public String getname() {return name;}
public double getGPA(){return gpa;}
public void setGPA(double newGPA){gpa = newGPA;}
public String getMajor() {return major;}
public String toString(){return name+", "+gpa+", "+ major;}
}
Write the method getHighestGPA that takes an array of Student objects and returns the Student object with the highest GPA on the array. If two or more students have the highest GPA return any one of them. Assume that GPA is >=0.0. The method returns null if studentArr is empty (has length zero).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
