Your program should read from the file, storing the names and corresponding email addresses in a dictionary as key-value pairs. Then, the program should display a menu that lets the user enter the numbers 1 through 5, each corresponding to a different menu item: 1) look up an email address 2) add a new name and email address 3) change an email address 4) delete a name and email address 5) save address book and exit When the user enters 1, the program should prompt them for a name, and then print the corresponding email address. If there is no dictionary entry under that name, the program should print, "Sorry, no contact exists under that name." When the user enters 2, the program should prompt them for a name and an email address, then add a new key-value pair to the dictionary. If there is an existing dictionary entry under the name, the program should print, "Sorry, that name already exists in the phonebook." When the user enters 3, the program should prompt them for a name and a new email address for that contact. It should change the value of the corresponding dictionary entry to match the new email address. If there is no dictionary entry under that name, the program should print, "Sorry, no contact exists under that name." When the user enters 4, the program should prompt them for a name and delete the corresponding dictionary entry. When the user enters 5, the program should write the names and email addresses in alphabetical order by first name to the file "out_phonebook.txt". Sample Run 1) look up an email address 2) add a new name and email address 3) change an email address 4) delete a name and email address 5) save address book and exit Enter your choice: 1↵ Enter name: Hermione Granger↵ Email address is: brightestwitch@hogwarts.edu 1) look up an email address↵ 2) add a new name and email address↵ 3) change an email address↵ 4) delete a name and email address↵ 5) save address book and exit Enter your choice: 2↵ Enter name: Sirius Black↵ Enter email: padfoot@hogwarts.edu 1) look up an email address↵ 2) add a new name and email address↵ 3) change an email address↵ 4) delete a name and email address↵ 5) save address book and exit Enter your choice: 5↵

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

Harry Potter
theboywholived@hogwarts.edu
Hermione Granger
brightestwitch@hogwarts.edu
Ron Weasley
roonilwazlib@hogwarts.edu
Draco Malfoy
myfatherwillhearaboutthis@hogwarts.edu
Severus Snape
halfbloodprince@hogwarts.edu
Albus Dumbledore
alasearwax@hogwarts.edu

Your program should read from the file, storing the names and corresponding email addresses in a dictionary as key-value pairs. Then, the program should display a menu that lets the user enter the numbers 1 through 5, each corresponding to a different menu item:

1) look up an email address
2) add a new name and email address
3) change an email address
4) delete a name and email address
5) save address book and exit

When the user enters 1, the program should prompt them for a name, and then print the corresponding email address. If there is no dictionary entry under that name, the program should print, "Sorry, no contact exists under that name."

When the user enters 2, the program should prompt them for a name and an email address, then add a new key-value pair to the dictionary. If there is an existing dictionary entry under the name, the program should print, "Sorry, that name already exists in the phonebook."

When the user enters 3, the program should prompt them for a name and a new email address for that contact. It should change the value of the corresponding dictionary entry to match the new email address. If there is no dictionary entry under that name, the program should print, "Sorry, no contact exists under that name."

When the user enters 4, the program should prompt them for a name and delete the corresponding dictionary entry.

When the user enters 5, the program should write the names and email addresses in alphabetical order by first name to the file "out_phonebook.txt".

Sample Run
1) look up an email address
2) add a new name and email address
3) change an email address
4) delete a name and email address
5) save address book and exit

Enter your choice: 1↵
Enter name: Hermione Granger↵
Email address is: brightestwitch@hogwarts.edu

1) look up an email address↵
2) add a new name and email address↵
3) change an email address↵
4) delete a name and email address↵
5) save address book and exit

Enter your choice: 2↵
Enter name: Sirius Black↵
Enter email: padfoot@hogwarts.edu

1) look up an email address↵
2) add a new name and email address↵
3) change an email address↵
4) delete a name and email address↵
5) save address book and exit

Enter your choice: 5↵

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 2 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