Topical Information

This program should emphasize the use of strings in conjunction with vectors and sorting.

Program Information

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.

Example Run

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!

$

Thought Provoking Questions

  1. How do you read names that might or might not contain spaces?

  2. How do you store multiple strings together in a single variable?

  3. 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!)

  4. How can you access a single string of a vector of strings?

  5. Can you pass a single string from a vector of strings to, say, a swap function?

  6. 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).

Options