Question: The program of Exercise P 8 . 1 7 is not very user - friendly because it requires the user to know the exact spelling

The program of Exercise P8.17 is not very user-friendly because it requires the user to know the exact spelling of the country name. As an enhancement, whenever a user enters a single letter, print all countries that start with that letter. Use a dictionary whose keys are letters and whose values are sets of country names.Algorithm for Programming Assignment 3
Keep the original program (solution to Exercise P8.17) up to the creation of the incomes dictionary
with the key (country name) and values (per capita income).
, Create a new dictionary (letters) with the key (alphabet letter) and values (a set of the
country names that start with the letter in the key). Follow the steps below to create this
dictionary:
O iterate over the keys (country names) in the first dictionary (incomes)
if the first letter of the key (country name) is not a key in the new dictionary
(letters)
, add a new entry to the dictionary: key: first letter of the country name,
value: an empty set
, add the country name to the set, indexed by the first letter of the
country name as the key
Modify the part for reading queries from the user and responding in the original program.
Follow the steps below for the user input and the program response:
Prompt the user for input
O if the text entered by the user is of length ==1 :
use the new dictionary (letters) to list the countries starting with that letter
O else use the text entered by the user to look for the country name in the first
dictionary (incomes) and
if found print the per capita income
else print the text entered is not a recognized country
 The program of Exercise P8.17 is not very user-friendly because it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!