Write a program that allows the user to create and maintain a list of contacts in a file named MyContacts.txt. Each contact will have a name and a phone number. In the file, each line should have a contact's name followed by their phone number you may assume that every contact's name will just be a single word (i.e. no last names) For example, if your file has two contacts in it, it might look something like this: Bob 555-1234 Jill 555-4321 Recall that if you try to open a file for reading before it exists, the program will crash. Therefore, assume the user will first try to add a contact as their first option (i.e. I won't try to print the list or print a number first when I'm testing your code). In the addContact method, when you open a file for appending, it will be created for you. In a while loop, continually ask the user what option they would like to choose. Each option (other than the quit option) should call a function which performs a specific task. Their options are: 1. Call a function named printList: This function should print out the data in MyContacts.txt in the following way: Contact 1: Bob Phone Number: 555-1234 Contact 2: Jill Phone Number: 555-4321 etc. 2. Call a function named findNumber which will find the phone number of a specific contact by asking the user enter a name. If the name is found in MyContacts.txt, return its corresponding phone number. Otherwise, return the empty string (quote-quote). Back in main, if a number is returned from findNumber, print it out. If the empty string is returned, tell the user the contact doesn't exit. 3. Call a function named addContact which will allow the user to add a contact to the file. In this function, ask the user to enter a name and phone number and then append these values to the end of MyContacts.txt. Again, you may assume that the user will only enter single-word names. 4. Quit the program

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

C++ Question 

Hello Please answer the following attached C++ programming question correctly, just as the prompt states. Please don't use advanced functions, just follow the instructions given and make sure the code is functioning properly. Please Do Not Copy and Paste Any Answers That Chegg Has For This Question. Thank you. 

Write a program that allows the user to create and maintain a list of contacts in a file named MyContacts.txt. Each
contact will have a name and a phone number. In the file, each line should have a contact's name followed by their
phone number
you may assume that every contact's name will just be a
single word (i.e. no last names)
For example, if your file has two contacts in it, it might look something like this:
Bob 555-1234
Jill 555-4321
Recall that if you try to open a file for reading before it exists, the program will crash. Therefore, assume the user will
fırst try to add a contact as their first option (i.e. I won't try to print the list or print a number first when l'm testing your
code). In the addContact method, when you open a file for appending, it will be created for you.
In a while loop, continually ask the user what option they would like to choose. Each option (other than the quit option)
should call a function which performs a specific task. Their options are:
1. Call a function named printList: This function should print out the data in MyContacts.txt in the following way:
Contact 1: Bob Phone Number: 555-1234
Contact 2: Jill Phone Number: 555-4321
etc..
2. Call a function named findNumber which will find the phone number of a specific contact by asking the user enter a
name. If the name is found in MyContacts.txt, return its corresponding phone number. Otherwise, return the empty
string (quote-quote). Back in main, if a number is returned from findNumber, print it out. If the empty string is returned,
tell the user the contact doesn't exit.
3. Call a function named addContact which will allow the user to add a contact to the file. In this function, ask the user
to enter a name and phone number and then append these values to the end of MyContacts.txt. Again, you may assume
that the user will only enter single-word names.
4. Quit the program
Transcribed Image Text:Write a program that allows the user to create and maintain a list of contacts in a file named MyContacts.txt. Each contact will have a name and a phone number. In the file, each line should have a contact's name followed by their phone number you may assume that every contact's name will just be a single word (i.e. no last names) For example, if your file has two contacts in it, it might look something like this: Bob 555-1234 Jill 555-4321 Recall that if you try to open a file for reading before it exists, the program will crash. Therefore, assume the user will fırst try to add a contact as their first option (i.e. I won't try to print the list or print a number first when l'm testing your code). In the addContact method, when you open a file for appending, it will be created for you. In a while loop, continually ask the user what option they would like to choose. Each option (other than the quit option) should call a function which performs a specific task. Their options are: 1. Call a function named printList: This function should print out the data in MyContacts.txt in the following way: Contact 1: Bob Phone Number: 555-1234 Contact 2: Jill Phone Number: 555-4321 etc.. 2. Call a function named findNumber which will find the phone number of a specific contact by asking the user enter a name. If the name is found in MyContacts.txt, return its corresponding phone number. Otherwise, return the empty string (quote-quote). Back in main, if a number is returned from findNumber, print it out. If the empty string is returned, tell the user the contact doesn't exit. 3. Call a function named addContact which will allow the user to add a contact to the file. In this function, ask the user to enter a name and phone number and then append these values to the end of MyContacts.txt. Again, you may assume that the user will only enter single-word names. 4. Quit the program
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Files and Directory
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
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