Advertisement
Guest User

Untitled

a guest
Mar 21st, 2021
743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. Write an address book program that stores your contacts' names and their
  2. email addresses.
  3.  
  4. The names and email addresses are originally stored in a file called
  5. phonebook.in, in the format:
  6.  
  7. Harry Potter
  8. theboywholived@hogwarts.edu
  9. Hermione Granger
  10. brightestwitch@hogwarts.edu
  11. Ron Weasley
  12. roonilwazlib@hogwarts.edu
  13. Draco Malfoy
  14. myfatherwillhearaboutthis@hogwarts.edu
  15. Severus Snape
  16. halfbloodprince@hogwarts.edu
  17. Albus Dumbledore
  18. alasearwax@hogwarts.edu
  19.  
  20. Your program should read from the file, storing the names and corresponding
  21. email addresses in a dictionary as key-value pairs. Then, the program
  22. should display a menu that lets the user enter the numbers 1 through
  23. 5, each corresponding to a different menu item:
  24.  
  25. 1) look up an email address
  26. 2) add a new name and email address
  27. 3) change an email address
  28. 4) delete a name and email address
  29. 5) save address book and exit
  30.  
  31. When the user enters 1, the program should prompt them for a name, and then
  32. print the corresponding email address. If there is no dictionary entry under
  33. that name, the program should print, "Sorry, no contact exists under that name."
  34.  
  35. When the user enters 2, the program should prompt them for a name and an email
  36. address, then add a new key-value pair to the dictionary.
  37.  
  38. When the user enters 3, the program should prompt them for a name and a new
  39. email address for that contact. It should change the value of the
  40. corresponding dictionary entry to match the new email address.
  41.  
  42. When the user enters 4, the program should prompt them for a name and delete
  43. the corresponding dictionary entry.
  44.  
  45. When the user enters 5, the program should write the names and email addresses
  46. in alphabetical order by first name to the file phonebook.out.
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement