Question: 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

 Can you do it using two different classes as there must

be two files in java(preferably eclipse) Objective: Create a database to hold

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; } }

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!