Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/** * Write the following STATIC methods * * getStudentWithHigherGpa, which has

ID: 3628324 • Letter: #

Question

/**
* Write the following STATIC methods
*
* getStudentWithHigherGpa, which has two Student parameters (s1 and s2). It returns the Student object with the larger gpa.
*
* swapGPAs, which has two Student parameters (s1 and s2). It has a void return type. It should swap the gpas of s1 and s2.
*
* testGetStudentWithHigherGpa, which has three student parameters (s1, s2, and expectedResult). This method should call the
* getStudentWithHigherGpa method, passing in s1 and s2, storing the result in a new Student variable called result.
* It should return true if result is equal to expectedResult, as determined by the equals method you wrote in Student.java.
*
* A main method, that creates a student named Jim with gpa 3.4, a student named Jane with gpa 3.6.
*/

This is what I have right now:
public class StudentMethods {
public static double getStudentWithHigherGpa(double s1 , double s2) {
double max =
return max;

}

public static void swapGPAs(double s1, double s2) {

}
public static boolean testGetStudentWithHigherGpa(double s1, double s2, double expectedResult){
if(result == expectedResult){

return true;
}

else{
return false;
}
}
}

I don't know how to figure out which of the student's GPAs is larger in the first one and how to do anything in the second one. Any help is appreciated! Lifesaver guaranteed!

Explanation / Answer

You need to make your functions static members of the Student class since it asks for them to be static. You need to have them both take s1 and s2 as Student objects, not doubles. If we assume the student class has a parameter "gpa" that is a double, these functions are shown below. class Student { public string name; public double gpa; public Student(string n, double g) { name = n; gpa = g; } public static Student getStudentWithHigherGpa(Student s1, Student s2) { if (s1.gpa > s2.gpa) { return s1; } else { return s2; } } public static void swapGPAs(Student s1, Student s2) { double temp = s1.gpa; s1.gpa = s2.gpa; s2.gpa = temp; } public static boolean testGetSTudentWithHigherGpa(Student s1, Student s2, Student expectedResult) { Student result = getStudentWithHigherGpa(s1,s2); return result == expectedResult; } public static void main(String[] args) { Student jim = new Student("Jim", 3.4); Student jane = new Student("Jane", 3.4); } };