Write an address book program that stores your contacts' names and their email addresses. The names and email addresses are originally stored in a file called phonebook.in, in the format: Harry Potter t..d@hogwarts.edu Hermione Granger b..h@hogwarts.edu Ron Weasley r..b@hogwarts.edu Draco Malfoy m..s@hogwarts.edu Severus Snape h..e@hogwarts.edu Albus Dumbledore a..x@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. 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. 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 phonebook.out.

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 an address book program that stores your contacts' names and their email addresses. The names and email addresses are originally stored in a file called phonebook.in, in the format: Harry Potter t..d@hogwarts.edu Hermione Granger b..h@hogwarts.edu Ron Weasley r..b@hogwarts.edu Draco Malfoy m..s@hogwarts.edu Severus Snape h..e@hogwarts.edu Albus Dumbledore a..x@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. 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. 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 phonebook.out.

 

Python Programming

SAMPLE RUN #1: python3 EmailAddress.py
Input File: phonebook.in
Hide Invisibles
Harry-Pottere
theboywholived@hogwarts.edu-
Ron-Weasleye
roonilwazlib@hogwarts.edue
Hermione Grangere
brightestwitch@hogwarts.edu-
Albus - Dumbledoree
alasearwax@hogwarts.edue
Severus Snaped
halfbloodprince@hogwarts.edue
Remus - Lupine
moony@hogwarts.edue
Peter-Pettigrewe
wormtail@hogwarts.edue
Sirius Blacke
padfoot@hogwarts.edue
Transcribed Image Text:SAMPLE RUN #1: python3 EmailAddress.py Input File: phonebook.in Hide Invisibles Harry-Pottere theboywholived@hogwarts.edu- Ron-Weasleye roonilwazlib@hogwarts.edue Hermione Grangere brightestwitch@hogwarts.edu- Albus - Dumbledoree alasearwax@hogwarts.edue Severus Snaped halfbloodprince@hogwarts.edue Remus - Lupine moony@hogwarts.edue Peter-Pettigrewe wormtail@hogwarts.edue Sirius Blacke padfoot@hogwarts.edue
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

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