Sorting Names
COMP 170
25 Points
The
purpose of this lab is to apply the principles of string manipulation and to
adapt a sorting algorithm for strings.
Write a
program called NameSort.cpp
that runs as follows:
Name? Bill Jones
Name? Sue Smith
Name? Beth Adams
Name? James Bell
Name?
After reversing, the
names are:
Jones, Bill
Smith, Sue
Adams, Beth
Bell, James
After sorting, the
names are:
Adams, Beth
Bell, James
Jones, Bill
Smith, Sue
Notes:
1. There will never be more than 100 names.
2. There is no limit to the length of the names.
3. Your program should stop asking for names when the
ENTER key is pressed in response to the “Name?” prompt, resulting in the empty
string.
4. You should write a ReverseName
function to change “John Doe” to “Doe, John”.
5. Sorting notes are available at http://www.harding.edu/USER/dsteil/WWW/170/Calendar/sorting.htm
. You also had another sorting
assignment earlier this semester.
Bring a printout of your lab
to class tomorrow.