Purchase Solution

Java Searching an Array for Exact Match Using Loops

Not what you're looking for?

Ask Custom Question

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:
o Peoria
o Kankakee
o Austin
o Boise

Attachments
Purchase this Solution

Solution Summary

The expert examines Java searching an array for exact match using loops.

Purchase this Solution


Free BrainMass Quizzes
Basic Networking Questions

This quiz consists of some basic networking questions.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

C# variables and classes

This quiz contains questions about C# classes and variables.

Javscript Basics

Quiz on basics of javascript programming language.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.