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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 10PE
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning