Answered step by step
Verified Expert Solution
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
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; iStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started