Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NameSearch ( 7 0 ) In the following problem use these two files which have been placed in the Programs / Lesson 2 / Homework

NameSearch (70)
In the following problem use these two files which have been placed in the Programs/Lesson2/Homework tab.
girlnames.txt - This file contains a list of the most popular names given to girls born in the United States for the years 2000 through 2009.
boynames.txt - This file contains a list of the most popular names given to boys born in the United States for the years 2000 through 2009.
I have simplified this by putting one name on each line
In main: (30)
You will need to create a number of String references and String array references
Get the names of the physical file with the boy's 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 boy's file.
Get the names of the physical file with the girl's 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 girl's file.
Ask the user if they wish to continue querying against the list. (see IO below)
The user should be able to enter a boy's name, a girl's 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 (20) 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 (10)
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: (10)
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 aren't 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: JasminMartin is one of the most popular boy's names.
Jasmin 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: Devon Enter a girl's name, or N if you do not wish to enter a girl's name: Camila Devon is one of the most popular boy's names.
Camila 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: Hubert
Enter a girl's name, or N if you do not wish to enter a girl's name: Delaney
Hubert is not one of the most popular boy's names.
Delaney 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: Edgar
Enter a girl's name, or N if you do not wish to enter a girl's name: Helena Edgar is one of the most popular boy's names.
Helena is not 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: Henrique Enter a girl's name, or N if you do not wish to enter a girl's name: Isabella Henrique is not one of the most popular boy's names. Isabella is one of the most popular girl's names. Do you wa
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions