Question
1. Create a hash with a set of names and phone numbers. Populate the hash with five sets of data. Ask the user which name
1. Create a hash with a set of names and phone numbers. Populate the hash with five sets of data. Ask the user which name they would like to look up the phone number for, and use that as the key to display the number.
2. Set up a hash that contains a few city names and their corresponding zip codes (guess if you don’t know them). Then, display the names of the cities and ask the user to enter one. Display the corresponding zip code.
Reverse the hash and display the zip codes, asking the user to choose one. Display the city for that zip code. You can display the lists of cities and zip codes any way you want, or display both at the same time with the keys function,
3. Modify the last program you wrote to:
- Display the current hash, and ask the user if they want to add a new entry. If they do, prompt for the city and zip and add it to the hash
- Display the hash again and ask if the user wants to delete an entry. If they do, ask for the hash key to delete, and remove that entry
- Perform the same lookups for city and zip as before, but check to make sure the keys exist. If not, display an error message.
Step by Step Solution
3.33 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
Part 1 Part 2 Answer 1 Code to Copy data Charlie 9966512345 Annie 8189841989 Harry Chand...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started