Write a program that illustrates you knowledge of maps and files. Create a map t
ID: 3533611 • Letter: W
Question
Write a program that illustrates you knowledge of maps and files. Create a map that contains an individuals Jnumber and their names. use a switch that will allow a user to enter the info into the map, select a person's name based on their jnumber and be able to delete an existing record in the map. Finally creat a method that stores the information from the map into a text file. close the file. exit the program.
The switch statement should ;look similar to this example:
A)d new record
D)elete a record
F)ind a person's name
L)ist all records
S)ave information in a file
Q)uit
Explanation / Answer
Please rate with 5 stars :)
Here I am assuming JNumber to be phone numbers
public class Hashmap {
private HashMap<String, Integer> name;
HashMap<String, Integer> namelist = new HashMap<String, Integer>();
Integer number;
String names;
/**
* @return the name
*/
Phone() {
// get user to enter name and number
Scanner scan = new Scanner(System.in);
System.out.println("enter name ");
names = scan.nextLine();
System.out.println("enter number ");
String nums = scan.nextLine();
number = Integer.parseInt(nums);
namelist.put(names, number); // set key and value to namelist object;
setName(namelist); //
}
void printValue() {
System.out.print(namelist.get(names));
}
public HashMap<String, Integer> getName() {
return name;
}
/**
* @param names
* the name to set
*/
public void setName(HashMap<String, Integer> names) {
this.name = names;
}
public static void main(String[] args) {
Phone ph = new Phone();
Gui window = new Gui();
System.out.println(ph.getName());
ph.printValue();
}
}
The other parts are easy to implement. Cheers!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.