Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Java: Write a program that creates: - An array of Strings of length 5 (I named mine keys ) - An array of ints
In Java:
Write a program that creates: - An array of Strings of length 5 (I named mine keys ) - An array of ints of length 5 (I named mine Do not use the ArrayList class. Your program should then do the following: - Get a string "key" from the user and an int value. It should store those in index 0 in the respective arrays - Repeat the above for indices 1 through 4 (ask the user for a string and int, and store them) You should then get a key to search for from the user. If the key is in the 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". 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 6Step 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