Question: Java Please create a class called Students a. Field: a sorted Map to store student data i. Map data types: studentid (Integer) and studentName (String)

 Java Please create a class called Students a. Field: a sorted

Java

Please create a class called Students a. Field: a sorted Map to store student data i. Map data types: studentid (Integer) and studentName (String) b. Methods: i.addStudent (accepts ID and Name) - adds new student to the Map ii. getStudentName (accepts an ID) - returns name: "Name Not Found" If ID doesn't exist in Map iii. getStudentID (accepts a name) - returns ID, if found; returns -1 if name doesn't exist in the Map 1. assume that no student name appears more than once in the map iv. removeStudent (accepts an ID) - removes the student whose id matches this ID 1. Throw an IllegalArgumentException with the message "1D not found" if it doesn't exist c. Please test this class in main by i. Creating and then calling a method in main called question2 as follows: 1. Please output "Question 2." on a new line 2. Create an instance of this Students class 3. Add one student to this object instance 4. Output the return value from both getters above a. Call each one with ids or names that both do and do not exist in the mar 5. attempt to remove a non-existent student - catch the Exception and output the error

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!