Question: Java Programming, please read instructions very very carefully Write a program that creates an integer array with 50 random values, prompts the user to enter
Write a program that creates an integer array with 50 random values, prompts the user to enter the index of an element in the array between 0 and 49, then displays the corresponding element value. If the specified index is out of bounds, display an error message (eg. "Out of Bounds") and ask the user to enter another index. Use a while loop that will keep prompting the user until a valid input is received. To handle invalid inputs, write two versions of your program: one that uses exception handling, and one that uses defensive programming. Assume a user will always enter numbers. Verify that the displayed element number is indeed from the index number entered list[50] of random int generated 48 5 8 59 29 3 51 33 2 98 76 72 55 69 34 8 58 72 55 33 95 72 43 86 9 13 71 80 34 63 51 28 73 26 55 99 70 23 49 55 27 69 47 12 9 14 18 33 55 16 Enter an index: 55 Out of Bound.: 50 Out of Bound.: 49 The element is 16
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
