The text file boynames.txt and girlnames.txt, which are included in the source code for this book, contain lists of the 1,000 most popular boy and girl names in the United States for the year 2005, as compiled by the SSN. These are blank-delimited where the most popular name is listed first, the second most popular name is listed second, and so on to the 1,000th most popular name, which is listed last. Each line consists of the first name followed by a blank space followed by the number of registered birth in the year using that name. For example, the girlnames.txt file begins with: Emily 25494 Emma 22532 This indicates the Emily is the most popular name with 25,494 registered namings, Emma is the second most popular with 22,532, and so on. Write a program that determines how many names are on both the boy’s and girls’ list. Use the following algorithm: Read each girl name as a String, ignoring the number of namings, and add it to a HashSet object. Read each boy names as a String, ignoring the number of namings, and add it to the same HashSet object. If the name is already in the HashSet, then the add method returns false. If you count the number of false returns, then this gives you the number of common namings Add each common name to an ArrayList and output all of the common names from this list before the program exists.
The text file boynames.txt and girlnames.txt, which are included in the source code for this book, contain lists of the 1,000 most popular boy and girl names in the United States for the year 2005, as compiled by the SSN.
These are blank-delimited where the most popular name is listed first, the second most popular name is listed second, and so on to the 1,000th most popular name, which is listed last. Each line consists of the first name followed by a blank space followed by the number of registered birth in the year using that name. For example, the girlnames.txt file begins with:
Emily 25494
Emma 22532
This indicates the Emily is the most popular name with 25,494 registered namings, Emma is the second most popular with 22,532, and so on.
Write a program that determines how many names are on both the boy’s and girls’ list. Use the following
- Read each girl name as a String, ignoring the number of namings, and add it to a HashSet object.
- Read each boy names as a String, ignoring the number of namings, and add it to the same HashSet object. If the name is already in the HashSet, then the add method returns false. If you count the number of false returns, then this gives you the number of common namings
- Add each common name to an ArrayList and output all of the common names from this list before the program exists.



Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images









