The program uses an array that contains valid names for 10 cities in the Illinois. You ask the user of the program to enter a city name; your program then searches the array for that city name. If it is not found, the program should print a message that informs the user that the city name is not found in the list of valid cities in Illinois.
The data file provided for this lab includes the input statements and the necessary variable declarations. You need to use a loop to examine all the items in the array and test for a match. You also need to set a flag if there is a match, and then test the flag variable to determine if you should print the "Not a city in Illinois" message. Comments in the code tell you where to write your statements. You can use the Mail Order Program in this chapter guide.
- Write a loop statement that examines the names of cities stored in the array.
- Write a code that tests for a match.
- Write code that, when appropriate, prints the message: Not a city in Illinois.
- Execute the program using the following as input:
The expert examines Java searching an array for exact match using loops.