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 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

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

C++ Question

Please answer the following attached C++ programming question correctly, just as the instruction states. Please don't "Flags" or "ios_bas". Do not copy/ paste the answer to this question from Chegg and don't just change the variable names from that Chegg answer. Please create it based on the instructions. A "copy/pasted" answer is not beneficial for me. 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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 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