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 (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
Write a
INPUT FILE
Joe
Sally
Joe
Sue
Sally
Adam
Joe
Adam
Adam
Joe
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
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images