Write a function in C++ using an array and C-string to detect whether the user entered a number or a name at prompts involving a list of the cities. If they've entered a number, proceed as normal. If they've entered a name, use a search to decide which city it was. (If the name 'matches' multiple cities, you should print a new — hopefully smaller — list of the matches for them to choose from.) The program let the user to enter the city name. The programs store the city into an array of city. After the user done inputting the name of the city. The program ask the user if he/she wants to search for the city or not. If the user say yes, the program will do a linear search to find the city that the user want. For example: City List: 1. Chicago , 2. Seattle, 3. LA , 4. New York If the user enter 2: show seattle. If the user enter a city: search the list and show the city.
Write a function in C++ using an array and C-string to detect whether the user entered a number or a name at prompts involving a list of the cities. If they've entered a number, proceed as normal. If they've entered a name, use a search to decide which city it was. (If the name 'matches' multiple cities, you should print a new — hopefully smaller — list of the matches for them to choose from.)
The program let the user to enter the city name. The programs store the city into an array of city. After the user done inputting the name of the city. The program ask the user if he/she wants to search for the city or not. If the user say yes, the program will do a linear search to find the city that the user want.
For example: City List:
1. Chicago , 2. Seattle, 3. LA , 4. New York
If the user enter 2: show seattle.
If the user enter a city: search the list and show the city.
Step by step
Solved in 3 steps with 2 images