In: Computer Science
DO IN JAVA
If you have downloaded this book’s source code (the companion Web site is available at www.pearsonhighered.com/gaddis), you will find the following files in the Chapter 07 folder:
GirlNames.txt – This file contains a list of the 200 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 200 most popular names given to boys born in the United States for the years 2000 through 2009.
Write a program that reads the contents of the two files into two separate arrays, or ArrayLists. 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.
BoyNames:
Jacob
Michael
Joshua
Matthew
Daniel
Christopher
Andrew
Ethan
Joseph
William
Anthony
David
Alexander
Nicholas
Ryan
Tyler
James
John
Jonathan
Noah
Brandon
Christian
Dylan
Samuel
Benjamin
Zachary
Nathan
Logan
Justin
Gabriel
Jose
Austin
Kevin
Elijah
Caleb
Robert
Thomas
Jordan
Cameron
Jack
Hunter
Jackson
Angel
Isaiah
Evan
Isaac
Mason
Luke
Jason
Gavin
Jayden
Aaron
Connor
Aiden
Aidan
Kyle
Juan
Charles
Luis
Adam
Lucas
Brian
Eric
Adrian
Nathaniel
Sean
Alex
Carlos
Bryan
Ian
Owen
Jesus
Landon
Julian
Chase
Cole
Diego
Jeremiah
Steven
Sebastian
Xavier
Timothy
Carter
Wyatt
Brayden
Blake
Hayden
Devin
Cody
Richard
Seth
Dominic
Jaden
Antonio
Miguel
Liam
Patrick
Carson
Jesse
Tristan
Alejandro
Henry
Victor
Trevor
Bryce
Jake
Riley
Colin
Jared
Jeremy
Mark
Caden
Garrett
Parker
Marcus
Vincent
Kaleb
Kaden
Brady
Colton
Kenneth
Joel
Oscar
Josiah
Jorge
Cooper
Ashton
Tanner
Eduardo
Paul
Edward
Ivan
Preston
Maxwell
Alan
Levi
Stephen
Grant
Nicolas
Omar
Dakota
Alexis
George
Collin
Eli
Spencer
Gage
Max
Cristian
Ricardo
Derek
Micah
Brody
Francisco
Nolan
Ayden
Dalton
Shane
Peter
Damian
Jeffrey
Brendan
Travis
Fernando
Peyton
Conner
Andres
Javier
Giovanni
Shawn
Braden
Jonah
Cesar
Bradley
Emmanuel
Manuel
Edgar
Erik
Mario
Edwin
Johnathan
Devon
Erick
Wesley
Oliver
Trenton
Hector
Malachi
Jalen
Raymond
Gregory
Abraham
Elias
Leonardo
Sergio
Donovan
Colby
Marco
Bryson
Martin
GirlsNames:
Emily
Madison
Emma
Olivia
Hannah
Abigail
Isabella
Samantha
Elizabeth
Ashley
Alexis
Sarah
Sophia
Alyssa
Grace
Ava
Taylor
Brianna
Lauren
Chloe
Natalie
Kayla
Jessica
Anna
Victoria
Mia
Hailey
Sydney
Jasmine
Julia
Morgan
Destiny
Rachel
Ella
Kaitlyn
Megan
Katherine
Savannah
Jennifer
Alexandra
Allison
Haley
Maria
Kaylee
Lily
Makayla
Brooke
Mackenzie
Nicole
Addison
Stephanie
Lillian
Andrea
Zoe
Faith
Kimberly
Madeline
Alexa
Katelyn
Gabriella
Gabrielle
Trinity
Amanda
Kylie
Mary
Paige
Riley
Jenna
Leah
Sara
Rebecca
Michelle
Sofia
Vanessa
Jordan
Angelina
Caroline
Avery
Audrey
Evelyn
Maya
Claire
Autumn
Jocelyn
Ariana
Nevaeh
Arianna
Jada
Bailey
Brooklyn
Aaliyah
Amber
Isabel
Danielle
Mariah
Melanie
Sierra
Erin
Molly
Amelia
Isabelle
Madelyn
Melissa
Jacqueline
Marissa
Shelby
Angela
Leslie
Katie
Jade
Catherine
Diana
Aubrey
Mya
Amy
Briana
Sophie
Gabriela
Breanna
Gianna
Kennedy
Gracie
Peyton
Adriana
Christina
Courtney
Daniela
Kathryn
Lydia
Valeria
Layla
Alexandria
Natalia
Angel
Laura
Charlotte
Margaret
Cheyenne
Mikayla
Miranda
Naomi
Kelsey
Payton
Ana
Alicia
Jillian
Daisy
Mckenzie
Ashlyn
Caitlin
Sabrina
Summer
Ruby
Rylee
Valerie
Skylar
Lindsey
Kelly
Genesis
Zoey
Eva
Sadie
Alexia
Cassidy
Kylee
Kendall
Jordyn
Kate
Jayla
Karen
Tiffany
Cassandra
Juliana
Reagan
Caitlyn
Giselle
Serenity
Alondra
Lucy
Kiara
Bianca
Crystal
Erica
Angelica
Hope
Chelsea
Alana
Liliana
Brittany
Camila
Makenzie
Veronica
Lilly
Abby
Jazmin
Adrianna
Karina
Delaney
Ellie
Jasmin
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Scanner;
public class BabyNames {
public static void main(String[] args) throws
Exception {
//to read boy names
BufferedReader br1 = new
BufferedReader(new FileReader("BoyNames.txt"));
//to read girl names
BufferedReader br2 = new
BufferedReader(new FileReader("GirlNames.txt"));
//array list to store boy
names
ArrayList<String> boy = new
ArrayList<String>();
//array list to store girl
names
ArrayList<String> girl = new
ArrayList<String>();
String line = br1.readLine();
// loading boy names
while (line != null) {
boy.add(line.trim());
line =
br1.readLine();
}
line = br2.readLine();
// loading girl names
while (line != null) {
girl.add(line.trim());
line =
br2.readLine();
}
// reading boy and girl names
Scanner sc = new
Scanner(System.in);
System.out.println("Enter
name");
String b = sc.nextLine();
// checking if it is in list
if (boy.contains(b) &&
girl.contains(b)) {
System.out.println("Name found in both boy and girl names.");
} else if (boy.contains(b)) {
System.out.println("Boy name found.");
} else if (girl.contains(b))
{
System.out.println("Girl name found.");
} else {
System.out.println("Name not found.");
}
br1.close();
br2.close();
sc.close();
}
}
Note : If you like my answer please rate and help me it is very Imp for me