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: _
-Read the input from users
-If the input is 1, display the message to ask users to type in a series of numbers separating by a space and stop by
pressing the Enter key.
-If the input is 2, display the message to ask users to type the name of the file to read , then read the array from the file.
-Display the question asking users to choose the method to sort the array:
1. Bubble sort
2. Selection sort
Select the number to continue:_
-Read the number: if 1, call the method bubbleSortArray, then display the result and the time of process
if 2, call the method selectionSortArray, then display the result and the time of process
Well, where's the problem? how far have you came yourself?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
People will help you with code, but it's a bit pointless to just do it all from scratch for you![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks