Create a student class in java


Discuss the below:

Q: Create a student class in Java that implements the Comparable interface. The class has:

- Two instance variables studentId (String) and gpa (double). StudentId would contain six-digit Student Id, and the value of GPA is between 0.00 and 4.00.

- Two constructors with the following headers:

--> public Student(String studentId, double gpa)

--> public Student(double gpa)

- Two accessor methods: public String getStudentId(), and public double getGPA().

- A public String toString() method that displays student information in the following format: "Student Id: " + studentId + " GPA: " +gpa

- A public int compareTo(Object object) that will compare two Student objects based on their student Ids.

 

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create a student class in java
Reference No:- TGS01934207

Now Priced at $20 (50% Discount)

Recommended (95%)

Rated (4.7/5)