Question: Write a program that uses the selection sort to sort the names found in the presidents.txt file. Have the program prompt the user for the
Write a program that uses the selection sort to sort the names found in the presidents.txt file. Have the program prompt the user for the filename. Make sure to check to see if the file was found. Read the names in a string array until you come to the end of the file...so no precounting of the names and using a for loop. Count the names as you read them so you will be able to use a for loops when working with the array. The names have spaces in them so use the appropriate command to read the full names. Once the names have been read in display the list of names. Put an appropriate heading before each printing of the names, as in Unsorted Presidents or Sort Presidents. Then use a selection sort to sort the names alphabetically. Display the sorted list of names. The file is found at the bottom of Moodle.
Must use functions. Suggested functions: load the array, print the array, and sort the array. The printing of the array function can be called from places.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
