Question: Java NameSearch In the following problem use these two files girlnames.txt This file contains a list of the most popular names given to girls born
Java NameSearch
In the following problem use these two files
girlnames.txt This file contains a list of the most popular names given to girls born in the United States for the years through
boynames.txt This file contains a list of the most popular names given to boys born in the United States for the years through
I have simplified this by putting one name on each line
In mai
You will need to create a number of String references and String array references
Get the names of the physical file with the boys names.
Call getArray with the name of the physical file a String It returns a reference to a String array with the names in the boys file.
Get the names of the physical file with the girls names.
Call getArray with the name of the physical file a String It returns a reference to a String array with the names in the girls file.
Ask the user if they wish to continue querying against the list. see IO below
The user should be able to enter a boys name, a girls name, or both, and the application will display messages indicating whether the names were among the most popular. To determine if the name is on the list call isFound with a reference to the name being searched for and the array of names as the two parameters. Ignore capitalization in your compares and in any other inputs.
The method getArray accepts the name of the physical file as a String
Create a File object.
Call getNumNames to determine the number of items in the file with a reference to the File object as the parameter.
Create a separate Scanner based on the File object
Read the list of names using the Scanner into an array
Close the Scanner
Return a reference to the Array
The method getNumNames accepts a reference to a File object
Create a Scanner based on this File object
Read in the lines one by one this is a dummy read in order to count the number of lines in the file since I have one name per line
Close the Scanner
Return the number of items in the file.
In isFound
Accept the name being searched for and the array with all the names. Return true if the name is found, otherwise false. Ignore capitalization in your compares.
Below you see a sample run that test. Be sure to search on first and last name in list, as well as on same name in the middle. Also check for names that arent on the list.
Please enter the name of the boy's file: boynames.txt
Please enter the name of the girl's's file: girlnames.txt
Do you want to search for names? Enter Y or N: Y
Enter a boy's name, or N if you do not wish to enter a boy's name: Jacob
Enter a girl's name, or N if you do not wish to enter a girl's name: Emily
Jacob is one of the most popular boy's names.
Emily is one of the most popular girl's names.
Do you want to search for names? Enter Y or N: Y
Enter a boy's name, or N if you do not wish to enter a boy's name: Martin
Enter a girl's name, or N if you do not wish to enter a girl's name: Jasmin
Martin is one of the most popular boy's names.
Jasmin is one of the most popular girl's names.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
