Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you do it using two different classes as there must be two files in java(preferably eclipse) Objective: Create a database to hold a collection

image text in transcribed

image text in transcribed

Can you do it using two different classes as there must be two files in java(preferably eclipse)

Objective: Create a database to hold a collection of numbers to be searched and sorted. Requirements: 1) Create a main class and a database class (must be two separate files) 2) Collect 5 random numbers from the user (keyboard) in the main method and store in an array. (not in ascending or descending order) 3) Create an instance of the database class in your main method and store the numbers array in the database using its constructor. 4) In the Database class, create a method that performs a bubble sort and returns a sorted array of the data (ascending and descending). Call this method from the main class and print the result to the screen. 5) In the Database class, create methods that return the min, average, and max values in the database. Call each of them from the main method and print the result to the screen. 6) In the Database class, create a method that searches for a value in the array using a binary search (example in the Assignment 2 folder) and returns the index of that value. Call this method from the main class and print the result to the screen. File Submission: Submit two source code files (.java files). One for the main class and one for the database class. 1/ Java program for implementation of Bubble sort and Binary Search class SortExample { public public static void main(string args[]) SortExample ob = new SortExample(); int[] arr = {64, 34, 25, 12, 22, 11, 90}; ob.bubblesort(arr); System.out.println("Sorted array"); ob.printArray(arr); int key = 22; int index = ob.BinarySearch(arr, key); System.out.println(" " + key + is at index: " + index); } void bubblesort(int[] arr) { int n = arr.length; for (int i = 0; i arr[j+1]) { // swap temp and arr[i] int temp = arr[i]; arrij] = arr[j+1]; arr[j+1] = temp; } } /* Prints the array */ void printArray(int arr[]) { int n = arr.length; for (int i=0; i= low) { mid = (high + low) / 2; if (arr[mid] key) { high = mid - 1; } else { return mid; } }<><-1>

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

More Books

Students also viewed these Databases questions

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago

Question

Explain the various methods of job evaluation

Answered: 1 week ago

Question

1. Prepare a flowchart of Dr. Mahalees service encounters.

Answered: 1 week ago