Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class named ArrayClass . The class will have: · Fields: -an int named s

ID: 3616535 • Letter: C

Question


Create a class named ArrayClass. The class will have:

·         Fields:

-an int named sizeOfArray

-An int named theArray

·         No-arg Constructor that assigns 0 to sizeOfArray and to each element of theArray

·         Parameter Constructor that accepts an int and an int array

·         Copy Constructor that accepts an object of the class ArrayApplication

·         Method bubbleSortArray has no argument. the method will sort the theArray and return the time of sorting process by using method System.nanoTime(); that returns a long number.

·         Method selectionSortArray has no argument. The method will sort the theArray and return the time of sorting process (as above)

·         method toString will print out the array elements.

For example: theArray = { 4, 8, 16, 77, 2, 57, 80 }

Output should be:

                Array:    4 8 16 77 2 57 80

Create a controlling class named ArraySortDemo that include the main method.

The main method will do the following:

-Display the question asking users how to enter the array elements by display the menu

1. Input from the keyboard

2. Input from the file

Select the number to continue: _

Explanation / Answer

importjava.util.Scanner; public class ArraySortDemo { publicstatic void main(String[]args) { int[] array; Scanner keyboard =new Scanner(System.in); System.out.println("How toenter the array elements?"); System.out.println(" 1.Input from the keyboard"); System.out.println(" 2.Input from the file"); System.out.print("Select thenumber to continue:"); int input =keyboard.nextInt(); String[] arrayData; if(input==1) { System.out.print("Enter the numbers: "); arrayData =keyboard.nextLine().trim().split(""); } else if(input==2) { System.out.print("Enter the name of the file:"); Scanner file = new Scanner(newFile(keyboard.nextLine().trim())); arrayData = file.nextLine(); } array = new int[arrayData.length]; for(int i= 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote