It's Raining Strings
๐ Background Information
No additional background information is needed to complete this problem.
This problem is available courtey of (James).
๐ฏ Problem Statement
Allow a user to enter the names of any number of local businesses. When a user enters a name, sort the current list of business names and display the results. Continue this process until the user exits the program.
โ Acceptance Criteria
- The program should print a welcome message when the user executes it.
- The user should be able to enter a business name that contains alphanumeric characters and special characters.
- You are allowed to use methods from the standard library (e.g.
std::sort
orstd::vector
) - The user should be able to enter โyโ, โYโ, โyesโ, or โYesโ to confirm that they want to enter another business name. Other inputs should exit the program gracefully.
- The program should print a goodbye message when the user exits.
๐ Dev Notes
There are no dev notes for this problem.
๐ฅ๏ธ Example Output
$ ./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 Business Sorting Program!
๐ Thought Provoking Questions
- What are some strategies that you can use to handle spaces in the business names?
- How might you store multiple strings / c-strings in a single variable?
- How might you sort strings / c-strings?
- How would you access a single row of a 2D array?
๐ผ Add-Ons For the Portfolio
(One Credit) C-strings Versus String Class
When completing this lab, you probably used c-strings or the C++ string class to store the business names. Refactor your code to use c-strings if you used the string class and vice versa. The output of the program should be identical to what you had before.
๐ Works Cited
- James, Jason. โItโs Raining Strings!โ Jason Jamesโ Homepage, http://craie-programming.org/122/labs/strsort.html, January 2017.