challenging program part(B)..
A. The Java program below is intended to sort an array of String objects. Complete the program by implementing the selectionSort function for arrays. A demo program from chapter 8 is provided with the assignment as an example of how to implement selection sort for an array of integers.
public static void main(String[] args)
{
String[] names = {"Joseph", "Aya", "Sally",
"Mohammad", "Ragda", "Bayan"};
// Display the unsorted array.
System.out.println("The unsorted values are:");
for (int I = 0; I < names.length; I++)
System.out.println(names[i] + " ");
System.out.println();
// Sort the array.
selectionSort(names);
// Display the sorted array.
System.out.println("The sorted values are:");
for (int I = 0; I < names.length; I++)
System.out.println(names[i] + " ");
}
B. Write a program to sort a list of names read from a text file. One challenge with this program is to determine the number of names in a file. I wrote a function called fileLineCount( ) to do this. I tested it in a file called FileLineCountDemo.java This program should give you some clues about reading the names from a file into an array. Once that is accomplished, the rest follows along the lines of part A.