Question: Programming Problem 15.10 Student implements Comparable with LabRat A student should have a first name, a last name, and a unique integer ID. For grade

Programming Problem 15.10 Student implements Comparable with LabRat

A student should have a first name, a last name, and a unique integer ID. For grade changes and removals, lookup should be by ID. The printout should be sorted by last name. If two students have the same last name, then use the first name as tie breaker. If the first names are also identical, then use the integer ID. Hint: Use two maps.

Here is a sample program run:

A)dd R)emove M)odify P)rint Q)uit AEnter the student's first name: JoeEnter the student's last name: SmithEnter the student's ID: 1001Enter the student's grade: CA)dd R)emove M)odify P)rint Q)uit AEnter the student's first name: SarahEnter the student's last name: SmithEnter the student's ID: 1002Enter the student's grade: B+A)dd R)emove M)odify P)rint Q)uit AEnter the student's first name: JoeEnter the student's last name: SmithEnter the student's ID: 2003Enter the student's grade: B+A)dd R)emove M)odify P)rint Q)uit AEnter the student's first name: HarryEnter the student's last name: PhamEnter the student's ID: 1996Enter the student's grade: FA)dd R)emove M)odify P)rint Q)uit MEnter the student's ID: 1002Enter the student's grade: AA)dd R)emove M)odify P)rint Q)uit REnter the student's ID: 1996A)dd R)emove M)odify P)rint Q)uit PJoe Smith 1001: C Joe Smith 2003: B+ Sarah Smith 1002: A A)dd R)emove M)odify P)rint Q)uit Q 

Your main class should be called Gradebook.

Complete the following class in your solution:

/** A student with an ID. */ public class Student implements Comparable { private String firstName; private String lastName; private int id; /** Constructs a Student object. @param aFirstName the first name @param aLastName the last name @param anId the ID */ public Student(String aFirstName, String aLastName, int anId) { firstName = aFirstName; lastName = aLastName; id = anId; } /** Gets the student's first name. @return firstName the first name */ public String getFirstName() { return firstName; } /** Gets the student's last name. @return lastName the last name */ public String getLastName() { return lastName; } /** Gets the student's ID. @return id the ID */ public int getId() { return id; } public int compareTo(Object otherObject) { . . . } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!