in c++ create a program that stores names in an array. Also …

in c++ create a program that stores names in an array. Also the program will end when “quit” is entered. Use a menu with the options: getName, sortName,displayName, findName, removeName. get name will get a name entered from the user, sort name will sort the names etc.

Answer

Introduction

In this assignment, we will develop a program in C++ that allows users to store names in an array and perform various operations on it. The program will display a menu with different options, including getting a name, sorting the names, displaying the names, finding a name, and removing a name. The program will only terminate when the user enters “quit” as input.

Approach

To implement this program, we will use an array data structure to store the names. We will provide functions corresponding to each menu option, allowing users to perform different operations on the array. Let’s discuss each of these options in detail.

1. Getting a Name

The “getName” function will prompt the user to enter a name and store it in the array. It will check if the array is already full and display an appropriate message if it is. If the name is successfully added, the function will display a success message.

2. Sorting the Names

The “sortName” function will sort the names in the array in alphabetical order. We will use a sorting algorithm, such as bubble sort or quicksort, to accomplish this. The function will display the sorted names once the sorting process is complete.

3. Displaying the Names

The “displayName” function will display all the names currently stored in the array. It will check if the array is empty and display a message if it is. The function will iterate over the array and print each name on a separate line.

4. Finding a Name

The “findName” function will prompt the user to enter a name to search for. It will then search the array for the entered name and display a message indicating whether the name was found or not.

5. Removing a Name

The “removeName” function will prompt the user to enter a name to remove from the array. It will search for the name and remove it if found. The function will display a success message if the name was successfully removed and an error message if the name was not found.

Conclusion

In this assignment, we will create a C++ program that allows users to store names in an array and perform various operations on it. The program will display a menu with options for getting a name, sorting the names, displaying the names, finding a name, and removing a name. The program will only terminate when the user enters the word “quit” as input. Our implementation will use an array data structure and provide corresponding functions for each menu option.

Do you need us to help you on this or any other assignment?


Make an Order Now