Question
Using java , I am trying to use serialization to read and write data to text file for this problem. Problem 2. Provide options to
Using java, I am trying to use serialization to read and write data to text file for this problem.
Problem 2. Provide options to save and load the file that stores two Map objects in the problem 1
Problem 1. 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started