Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that keeps a map in which the keys of the map are objects of class Student. An student should have a first

Write a program that keeps a map in which the keys of the map are objects of class Student. An student should have a first name, a last name, and a unique integer student identification. For the class grading (A, B, C, D, and F) changes and removals, lookup should be by student identification. Prompt the user of the program to add or remove students, to modify the grade, or to print all the grades including student names. 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 student identification. Supply compatible hashCode and equals methods to the Student class. Test the hash code by adding the student objects to a hash set.

Implementing the following methods:

public static printMenuAndGetChoice()

/** Adds a student based on user input. Prints an error if a student is added that already exists in the map. @param GradeMap the map to associate student object with a grade @param StudentMap the map to associate student id with an student. */

/** Removes a student from the map based on user input @param GradeMap the map to associate student object with a grade. @param StudentMap the map to associate student id with an student. */

/** Modifies an entry based on user input. Prints an error if an invalid student is modified. @param GradeMap the map to associate student object with a grade. @param StudentMap the map to associate student id with an student */

/** Prints the students and grades @param GradeMap the map to print */

Hint:

Use two 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 to Expert-Tailored 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

Recommended Textbook for

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions