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
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