NameSearching Program
Description
There are a list of names stored in an external data file.This program reads the names from the data file and use an ArrayList of String to store them.
Then the program proceeds to use several methods to print the ArrayList and search a particular name.
Select the data file
Read the name to fill in the ArrayList
Print the ArrayList
Search a particular name in the ArrayList
Read the name to fill in the ArrayList
Print the ArrayList
Search a particular name in the ArrayList
Associated Concepts:
ArrayList
Algorithm:
main method:
readData method definition:
search method definition:
Create an ArrayList of String
Select the data file use JFileChooser object
Call methods to:
Select the data file use JFileChooser object
Call methods to:
Read names in the data file to populate the ArrayList
Print the ArrayList
Search a particular name
Print the result
Print the ArrayList
Search a particular name
Print the result
readData method definition:
while loop: as long as the data file has data item
Read the next name and add it to the ArrayList
search method definition:
For each name in the ArrayList
If the loop ended without returning true
Not found and return false
If the name is equal to the searched name
Found it and return true
Found it and return true
If the loop ended without returning true
Not found and return false
Boy Names Data File
Girl Names Data File