Write a program in C++ that reads a list of 10 names from a file and stores them in an array. Next, allow the user to search for the number of instances of a name. The program should prompt a user for a name and output the total number of instances of that name entered to the screen and to a file (see example input and output below). It should continue to prompt for names until the word done is typed in. For this lab, use the string data type as opposed to char to store the names (i.e. don’t use c-strings). Input File Joe Sally Joe Sue Sally Adam Joe Adam Adam Joe Output File (be sure to output the class heading to the output file) (There should be 10 spaces between the columns) 8. NAME INSTANCES 9. ---- --------- 10. Joe 4 11. Sally 2 12. Adam 3 13. Sue 1 14. John - Expected output in image below
Write a
Input File
Joe
Sally
Joe
Sue
Sally
Adam
Joe
Adam
Adam
Joe
Output File (be sure to output the class heading to the output file)
(There should be 10 spaces between the columns)
8. NAME INSTANCES
9. ---- ---------
10. Joe 4
11. Sally 2
12. Adam 3
13. Sue 1
14. John -
Expected output in image below
![EXPECTED Screen INPUT (in green) / OUTPUT (in blue)
(Be sure to output the class heading in the Screen I/O as well as the output file)
8. Who do you want to search for (enter done to exit)? Joe
9. There are 4 instances of the name Joe.
10.
11. Who do you want to search for (enter done to exit)? Sally
12. There are 2 instances of the name Sally.
13.
14. Who do you want to search for (enter done to exit)? Adam
15. There are 3 instances of the name Adam.
16.
17. Who do you want to search for (enter done to exit)? Sue
18. There is one instance of the name Sue.
19.
20. Who do you want to search for (enter done to exit)? John
21. John's name does not exist in this list.
22.
23. Who do you want to search for (enter done to exit)? done
24.
25. Thank you for using my program.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fda56195c-7ad4-4699-8e57-859d695a4564%2Fa7d35a95-943b-4c0d-9d06-00d2acefaa52%2Fw7943h8_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)