Answer:
Here the code is given as follows,
Step-by-step explanation:
Code:
#include <iostream>
#include <string>
#include <list>
using namespace std;
std::string readName ();
void display (list <std::string>);
bool promptContinue ();
int main()
{
std::string Business = "";
list <std::string> Array;
bool Continue = true;
do {
//enter input items
Array.push_back(readName ());
//sort business
Array.sort();
//display business
display (Array);
}while(promptContinue ());
return 0;
} //end of main function
std::string readName ()
{
std::string _Business = "";
cout << "Please enter the name of a business: ";
getline (cin, _Business);
return _Business;
}
void display (list <std::string> _Array)
{
cout << "Your businesses are: " << endl;
int i = 0;
while (i < _Array.size ())
{
cout << _Array.front () << endl;
_Array.push_back (_Array.front ()); // This loops the front of the list to the back this makes it possible to not use an iterator
_Array.pop_front ();
i++;
}
}
bool promptContinue ()
{
std::string prompt = "";
cout << "Another Business? ";
cin >> prompt;
cin.ignore (); // Clear the whitespace leftover from cin
return (prompt == "yes");
}