Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this lab, you will need to use Java's HashMap class (java.util.HashMap) The goal is to produce a (very simple) system for storing and retrieving
In this lab, you will need to use Java's HashMap class (java.util.HashMap) The goal is to produce a (very simple) system for storing and retrieving student ID numbers. The text file provided contains a few random names (I actually found a utility online that produces lists of randomly generated names. Until today I would have thought such a thing was useless.) associated with random numbers. You will need to read in the file line by line, adding each name/ID pair to the map. The names should be used as keys, and the ID numbers should be stored as the values in the map. The student ID numbers can be stored as either String values or Integer values. Note that the ID numbers can not be stored as ints, be cause the HashMap class only supports object references as values, not primitives. When the map is created, the program should display a menu, as follows: What would you like to do? A: Add a student R: Remove a student. S: Search for a student's ID. 0: Quit. Please enter your choice: If the user selects "A", he/she should be asked to provide a name and an id number, which should then be added to the HashMap. If the user selects "R" he/she should be asked for the name of the student to be removed and, obviously, remove it. If the user selects "S" the program should ask for a name and print the associated student ID number. When removing a student or searching for a given student, if the name provided is not a key in the map an error message should be printed. Once the operation requested by the user, The above menu should be displayed again. This should be repeated until the user selects "Q", at which point the program should terminate after printing some fare well message
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