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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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

 

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.
Transcribed Image Text: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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY