Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

Define Trade Mark.

Answered: 1 week ago

Question

What is cost plus pricing ?

Answered: 1 week ago

Question

1. What are the types of wastes that reach water bodies ?

Answered: 1 week ago