Phonebook - pomo
Мъчих се над тази задача, но нещо не ми се получава отоговора, ако някой я е решил или може да я реши да удари едно рамо:)
1.Phonebook
Write a program that receives some info from the console about people and their phone numbers. Each entry should have just one name and one number (both of them strings).
On each line, you will receive some of the following commands:
- A {name} {phone} – adds entry to the phonebook. In case of trying to add a name that is already in the phonebook you should change the existing phone number with the new one provided.
- S {name} – searches for a contact by given name and prints it in format "{name} -> {number}". In case the contact isn't found, print "Contact {name} does not exist.".
- END – stop receiving more commands.
Examples
Input |
Output |
A Nakov 0888080808 S Mariika S Nakov END |
Contact Mariika does not exist. Nakov -> 0888080808 |
A Nakov +359888001122 A RoYaL(Ivan) 666 A Gero 5559393 A Simo 02/987665544 S Simo S simo S RoYaL S RoYaL(Ivan) END |
Simo -> 02/987665544 Contact simo does not exist. Contact RoYaL does not exist. RoYaL(Ivan) -> 666 |
A Misho +359883123 A Misho 02/3123 S Misho END |
Misho -> 02/3123 |
Hints
- Parse the commands by splitting by space. Execute the commands until “END” is reached.
- Store the phonebook entries in Dictionary<string, string> with key {name} and value {phone number}.