Last Java assignment for the semester.
here is the description for my last assignment:
--------------------------------------------------------------------------
Given the following array
{23,54,32,56,78,987,5,4,21,12,845,999,888,333,222, 111,444,555}
Create a class, SortAlgorithms that contain this array.
Within this class develop two methods:
int[]selection(int[]arrayin,char updown){...}
int[]insertion(int[]arrayin.char updown){...}
The selection method implements a selection sort on the integer array passed to it and returns the sorted array. The second parameter updown is a character which has one of two values. An "a" to sort the array in ascending order and a "d" to sort the array in descending order.
The insertion method implements a insertion sort on the integer array passed to it and returns the sorted array. The second parameter updown is a character which has one of two values. An "a" to sort the array in ascending order and a "d" to sort the array in descending order.
The class should contain a method that calls each of these methods twice. Once with the flag set for ascending order, once with the flag set for descending order.
The class should print out the sorted arrays each time they are sorted and indicate in the output whether they were sorted in ascending or descending order.
--------------------------------------------------------------------------
I did try to make one method for a selection sort but i'm having some difficulty making the code.
Here is my code I tried so far:
public class SortAlgorithms { public static void main(String[] args) { - Pastebin.com
It's probably all wrong, so I will need to know which is right.