Question: In Java, Write a program that creates a HashMap with Strings as the key and Integers as the value Write a program that creates a

In Java, Write a program that creates a HashMap with Strings as the key and Integers as the value

In Java, Write a program that creates a HashMap with Strings asthe key and Integers as the value Write a program that creates

Write a program that creates a HashMap with Strings as the key and Integers as the value. Your program should then get 5 String key/Integer value pairs from the user, and store them in the HashMap. You should then get a key to search for from the user. If the key is in the keys array, then you should print the value at the same index in the values array. If the key is not in the keys array, then you should print "not found". Note: this is the same programming appetizer as previously done with two arrays! Sample I/O Run 1: Enter key 1 asdf Enter value 1 7 Enter key 2 qwer Enter value 2 8 Enter key 3 zxcv Enter value 3 10 Enter key 4 fdsa Enter value 4 13 Enter key 5 i Enter value 5 1 Enter key to display value for i Value for i is 1 Run 2 (key not found): Enter key 1 asdf Enter value 1 7 Enter key 2 qwer Enter value 2 8 Enter key 3 zxcv Enter value 3 10 Enter key 4 fdas Enter value 4 1 Enter key 5 i Enter value 5 5 Enter key to display value for asf Key asf not found Run 3: Enter key 1 a Enter value 1 1 Enter key 2 b Enter value 2 2 Enter key 3 c Enter value 3 3 Enter key 4 d Enter value 4 6 Enter key 5 e Enter value 5 0 Enter key to display value for d Value for d is 6

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!