Question: Write a program that will generate 5 random integers between 1 and 10 and store them in an ArrayList (see 2.10 if you don't remember

Write a program that will generate 5 random integers between 1 and 10 and store them in an ArrayList (see 2.10 if you don't remember how to generate random integers). Ask the user for an integer to search for in the list, then output the index position of that integer or state that their integer is not in the list. Finally, sort the list, then output the contents of the sorted list. You will use two static methods: public static int search(ArrayList list, int num) searches the list for the user's integer and returns the index position of where it is found, or -1 if it is not found use sequential (linear) search starting at the END of the array and moving toward the beginning if the user's integer appears more than once, return the larger index public static void sort(ArrayList list) uses Selection Sort starting at the END of the list and moving toward the beginning Example output: Enter an integer: 3 3 is at index position 4 The sorted list is: [2, 3, 5, 8, 9] Enter an integer: 3 3 is not in the list The sorted list is: [2, 4, 5, 7, 10] IT MUST OUTPUT SORTED LIST FROM SMALLEST TO GREATEST

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!