Q write a program that store names to an array and accepts names until “quit” is entered. The program includes a menu having these choices : getNames, sortNames, displayNames, findName, removeName. all of which are in there own funtions. and you can enter names like this “John Doe” at the keyboard but are converted to this “Doe, John” before being added to the storage list (array or vector). HINT: using str.find(substr, pos) function to find the ‘ ’ between the first name and last name entered; and then using str.substr(pos, num) function to extract the first name and last name; finally, concatenate the last name, ‘,’, and the first name to form the required string. 24 Mar 2016, 12:23 PM Customer Add another function that uses a stringstream to create and return a new string made up of only the last names in the list (pass the list to the function). Enclose each last name with double quotes. You will need to find where each last name ends in the string then extract just the last name. HINT: You will need the same functions mentioned in question 6 to find the ‘,’ at the end of each last name, and extract the last name

Program Description:

The program you are asked to create will store names in an array and will continue accepting names until the user enters “quit”. The program will have a menu with the following options: getNames, sortNames, displayNames, findName, and removeName. Each of these options will be implemented as separate functions.

Additionally, you are requested to add another function that uses a stringstream to create and return a new string containing only the last names from the list. Each last name should be enclosed in double quotes. To accomplish this, you will need to find where each last name ends in the string and extract just the last name. The same functions used in question 6, such as str.find(substr, pos) and str.substr(pos, num), can be used to find the comma at the end of each last name and extract the last name.

To convert the entered names from the format “John Doe” to “Doe, John”, the program could use the following approach: first, find the space between the first name and last name using str.find(substr, pos) and save the position of the space. Then, use str.substr(pos, num) to extract the first name and last name. Finally, concatenate the last name, comma, and first name to form the required string.

By following this approach, the program will be able to store the converted names in a storage list, which could be implemented as an array or vector.

To implement the menu options:

1. getNames: This function will prompt the user to enter names until “quit” is entered. The program should convert each name to the required format before adding it to the storage list.

2. sortNames: This function will sort the names in the storage list alphabetically.

3. displayNames: This function will display all the names in the storage list in their current order.

4. findName: This function will prompt the user to enter a name to search for in the storage list. It will then check if the name exists in the list and display an appropriate message.

5. removeName: This function will prompt the user to enter a name to remove from the storage list. If the name exists in the list, it will be removed and the user will be notified. Otherwise, an appropriate message will be displayed.

Adding the additional function to create a new string consisting of only the last names enclosed in quotes will involve using a stringstream to extract each last name from the storage list and concatenating them together with quotes.

Overall, this program will provide various functionalities to manipulate the names stored in the storage list, including adding names in the required format, sorting them, displaying them, finding specific names, removing names, and creating a new string of last names enclosed in quotes.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer