Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java , Write a program that keeps a map in which the keys of the map are objects of class Student. A student should

In java , Write a program that keeps a map in which the keys of the map are objects of class Student. A student should have a first name, a last name, and a unique integer ID. For the grade changes and removals, lookup should be by ID. Prompt the user of the program to add or remove students, to modify the grades, or to print all the grades. The printout should be sorted by last name. If two students have the same last name, then use the first name as a tie breaker. If the first names are also identical, then use the integer ID. Supply compatible hashCode and equals methods to the Student class. Test the hash code by adding the Student objects to a hash set.

Hint:

Usetwo maps.Calculates a hashcode by combining the hashcodes of the instance variables. @return a hashcode dependant on the instance variables */ public int hashCode() { final int HASH_MULTIPLIER = 29; int h = HASH_MULTIPLIER * firstName.hashCode() + lastName.hashCode(); h = HASH_MULTIPLIER * h + ((Integer)id).hashCode(); return h; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions