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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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 (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.
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 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education