This program should emphasize the use of strings in conjunction with vectors and sorting.
Allow the user to enter the names of several local businesses. Sort the business names and display the results. Continue this process until they are out of business names.
Please use good functional decomposition to make your development easier. (Perhaps one for sorting a vector of strings, another for swapping two strings, one for displaying a vector of strings, and others to maintain the user interface. This program has good places to use libraries, too, btw.)
Note: You are NOT allowed to use the standard library function sort. Choose one of the sorts we learned about in Chapter 6 and code that yourself.
As an example the program interaction might look something like (the parts in this color are typed by the user):
$ ./busisort.out Welcome to the Business Sorting Program!!! Please enter the name of a business: WalMart Your business is: WalMart Another business? y Please enter the name of a business: JC Penney Your businesses are: JC Penney WalMart Another business? Y Please enter the name of a business: Merlin Muffler Your businesses are: JC Penney Merlin Muffler WalMart Another business? yes Please enter the name of a business: Appleby's Your businesses are: Appleby's JC Penney Merlin Muffler WalMart Another business? Yes Please enter the name of a business: Zippy's Your businesses are: Appleby's JC Penney Merlin Muffler WalMart Zippy's Another business? no Thank you for using the BSP!! Endeavor to have an egregious day! $
How do you read names that might or might not contain spaces?
How do you store multiple strings together in a single variable?
How do you sort strings? (Hint: The online notes show several sorts for numbers and characters. Do you need to modify these for use with strings? How/why not?) (NO, you cannot use the sort function from the algorithm library!)
How can you access a single string of a vector of strings?
Can you pass a single string from a vector of strings to, say, a swap function?
How can your 'again' question accept either characters or words? Be case insensitive? Does this require the use of strings? Why/why not?
This assignment is (Level 3.5).
Add (Level 0.5) to ensure their business names are capitalized correctly upon output (first letter capital, all others lower-case).
Add (Level 0.5) to allow for correct capitalization of hyphenated business names.
Add (Level 0.5) to allow for correct capitalization of apostrophized business names.
Add (Level 1) to allow for correct capitalization of Mc and Mac business names. (Don't worry about Mackey vs. MacKenzie — those kinds of issues would go into the following bit:)
You can also add (Level 1) for a [maximum] one page discussion on why accounting for De, La, and Le name prefixes would be much trickier. Suggest at least one possible implementation and then show why it won't work.
Add (Level 1.5) to make a single function to aid in the implementation of all three of the above capitalization-correction processes. (Abstraction is a powerful tool..!)
Perhaps it could be called something like:
fix_caps(user_text, "-"); fix_caps(user_text, "'"); fix_caps(user_text, "Mc"); fix_caps(user_text, "Mac");
Add (Level 0.5) to reuse your function to compare strings without regard for case during sorting. (If you did any of the options there, they will increase this option's level by half of their original value! It's like getting to turn in your paper on sloths for both biology and writing class...except I'm teaching both so I'm not quite as silly as to let you have full credit twice...*grin* *smile*)