diff --git a/src/main/java/Unit7/U7_L5_Activity_One.java b/src/main/java/Unit7/U7_L5_Activity_One.java new file mode 100644 index 0000000..ec6a0a0 --- /dev/null +++ b/src/main/java/Unit7/U7_L5_Activity_One.java @@ -0,0 +1,23 @@ +package Unit7; + +// Have to get rid of package statement + +public class U7_L5_Activity_One { + public static void sortAndPrintReverse(String[] arr) { + for (int i = 0; i < arr.length; i++) { + int high = i; + for (int j = i + 1; j < arr.length; j++) { + if (arr[j].compareTo(arr[high]) > 0) { + high = j; + } + } + String temp = arr[i]; + arr[i] = arr[high]; + arr[high] = temp; + } + + for (int i = 0; i < arr.length; i++) { + System.out.print(arr[i] + " "); + } + } +} diff --git a/src/main/java/Unit7/U7_L5_Activity_Two.java b/src/main/java/Unit7/U7_L5_Activity_Two.java new file mode 100644 index 0000000..583a88d --- /dev/null +++ b/src/main/java/Unit7/U7_L5_Activity_Two.java @@ -0,0 +1,30 @@ +package Unit7; + +// Have to get rid of package statement + +import java.util.ArrayList; + +public class U7_L5_Activity_Two +{ + + public static void selectSortReverse(ArrayList list){ + + for(int i=0; ilist.get(largestIndex)){ + largestIndex=j; + } + } + int temp = list.get(i); + + list.set(i, list.get(largestIndex)); + list.set(largestIndex, temp); + } + + System.out.println(list); + + } + +} +