/** * Make a class called Student which has: * * INSTANCE VARIABLES: * name, a S
ID: 3628325 • Letter: #
Question
/**
* Make a class called Student which has:
*
* INSTANCE VARIABLES:
* name, a String
* gpa, a double
*
* A CONSTRUCTOR with parameters String, double corresponding to the name and gpa (IN THAT ORDER)
*
* INSTANCE METHODS
* getName, which has no parameters and returns the name of the student
* getGpa, which has no parameters and returns the gpa of the student
* setName, which has a String parameter and sets the name variable of the student
* setGpa, which has a double parameter and sets the gpa variable of the student.
* equals, which has a Student parameter named s. This method should return true if
* the name and gpa of s are equal to the name and gpa of this object. Otherwise, return false.
*/
public class Student {
//Instance Variables
String name;
double gpa;
//Constructor
public Student(String n, double g) {
name = n;
gpa = g;
}
//Instance Methods
//getName, which has no parameters and returns the name of the student
public String getName(){
return name;
}
//getGpa, which has no parameters and returns the gpa of the student
public double getGpa(){
return gpa;
}
//setName, which has a String parameter and sets the name variable of the student
public void setName(String n){
name = n;
}
//setGpa, which has a double parameter and sets the gpa variable of the student.
public void setGpa(double g){
gpa = g;
}
//equals, which has a Student parameter named s. This method should return true if the name and gpa of s are equal to the name and gpa of this object. Otherwise, return false.
public static boolean equals()
}
I got almost everything but the last part. Any help? Lifesaver gauraunteed.
Explanation / Answer
public static boolean equals(Student s) { return (s.name == name) && (s.gpa == gpa); }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.