•Create a user-defined class ( Number.java) that contains…

•Create a user-defined class ( Number.java) that contains
•variables: name, age
•constructor to save name & age
•methods: getName(), getAge()
•Create the test program (FD.java)

Declare a HashMap that contains the user-defined class
.•Ask for the user to select one of the following menu.
1) add 2) remove 3)quit
if the user’s selection is 1),
•ask for id, name, age
•add to the hashmap using the constructor. Key must be the id
•generate success-message
•print the size of the hashmap and all the current data in the hashmap

If selection is 2)
•ask for an id to be removed
•if the id is not in the hashMap, generate an error messge.
•use .containsKey(key) to check if the key is in the hashmap
•If the id is in the hashMap, remove it and generate success-message
•print the size of the hashmap and all the current data in the hashmap
If selection is 3)
terminate the program
try-catch for input validation is not need.
OUTPUT:
HashMap add/remove test
Select 1)add 2)remove 3)quit
1
Input ID
101
Input Name:
Tom
Input age
19
101 added successfully
Current Members: 1
id: 101 name: Tom age: 19
Select 1)add 2)remove 3)quit
1
Input ID
102
Input Name
Sum
Input age
18
102 added successfully
Current Members: 2
id: 101 name: Tom age: 19
id: 102 name: Sum age: 18
Select 1)add 2)remove 3)quit
2
Input ID to be removed:
104
Can’t find 104
Current Members: 2
id: 101 name: Tom age: 19
id: 102 name: Sum age: 18
Select 1)add 2)remove 3)quit
2
Input ID to be removed:
102
102 successfully removed!
Current Members: 1
id: 101 name: Tom age: 19
Select 1)add 2)remove 3)quit
3
Bye!
structure of main test program
public static void main(String[] args) {
System.out.println(“HashMap add/remove test”);
while (true) {
System.out.println();
System.out.println(“Select 1)add 2)remove 3)quit”);
int select = input.nextInt() ;
if (select==1) {
add();
printAll();
}
if (select==2) {
remove();
printAll();
}
if (select==3) {
System.out.println(“Bye!”);
break;
}
}
}

Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount