Question

In: Computer Science

PLEASE DO IN JAVA AND USING REPL.IT Below are the two files, boysNames.txt and GirlsNames.txt Write...

PLEASE DO IN JAVA AND USING REPL.IT

Below are the two files, boysNames.txt and GirlsNames.txt

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

Solutions

Expert Solution

Please find the answer below:-

Code for displaying File content :-

Output:-

Code for finding names in the FIle:

Output 1:-

Output 2:

Thanks.
Hope you like the answer.

Code for displaying File content :-

package FileReadDemo;

import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.FileReader;
class Main {
public static void main(String[] args) throws IOException {
System.out.println("Hello world!");
ArrayList<String> boysNames = new ArrayList<String>();
ArrayList<String> girlsNames = new ArrayList<String>();
// Since file has dynamic size data, so consider ArrayList.
       File boysFileName = new File("boysNames.txt");
File girlsFileName = new File("GirlsNames.txt");
       FileReader frBoys = new FileReader(boysFileName);
FileReader frGirls = new FileReader(girlsFileName);
       BufferedReader brBoys = new BufferedReader(frBoys);
BufferedReader brGirls = new BufferedReader(frGirls);
// used for reading the file
       while (brBoys.ready()) { // loop will break at EOL(End Of Line)
           boysNames.add(brBoys.readLine()); // Adding file contents to an ArrayList.
       }
System.out.println("BoyNames");
for(String b:boysNames){
System.out.println(b);
}
while (brGirls.ready()) { // loop will break at EOL(End Of Line)
           girlsNames.add(brGirls.readLine()); // Adding file contents to an ArrayList.
       }
System.out.println("GirlNames");
for(String g:girlsNames){
System.out.println(g);
}
  
}
}

Code for finding names in the FIle:

import java.util.ArrayList;

import java.io.InputStreamReader;

import java.util.List;

import java.util.Arrays;

import java.io.BufferedReader;

import java.io.File;

import java.io.IOException;

import java.io.FileReader;

class Main {

public static void main(String[] args) throws IOException {

System.out.println("Hello world!");

String inputName;

ArrayList<String> boysNames = new ArrayList<String>();

ArrayList<String> girlsNames = new ArrayList<String>();

List userInputName = new ArrayList<String>();

// Since file has dynamic size data, so consider ArrayList.

    File boysFileName = new File("boysNames.txt");

File girlsFileName = new File("GirlsNames.txt");

    FileReader frBoys = new FileReader(boysFileName);

FileReader frGirls = new FileReader(girlsFileName);

    BufferedReader brBoys = new BufferedReader(frBoys);

BufferedReader brGirls = new BufferedReader(frGirls);

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

// used for reading the file

    while (brBoys.ready()) { // loop will break at EOL(End Of Line)

      boysNames.add(brBoys.readLine()); // Adding file contents to an ArrayList.

    }

System.out.println("Enter a Boy name or Girl name or both: ");

inputName = br.readLine();

String str[] = inputName.split(" ");

userInputName = Arrays.asList(str);

for(String b:boysNames){

for(int i=0;i<userInputName.size();i++){

if(((String)userInputName.get(i)).equalsIgnoreCase(b)){

System.out.println("Boy Name is present: ");

System.out.println(b);

}

}

}

while (brGirls.ready()) {

// loop will break at EOL(End Of Line)

      girlsNames.add(brGirls.readLine()); // Adding file contents to an ArrayList.

    }

for(String g:girlsNames){

for(int i=0;i<userInputName.size();i++){

if(((String)userInputName.get(i)).equalsIgnoreCase(g)){

System.out.println("Girl Name is present: ");

System.out.println(g);

}

}

}

}

}

Thanks.
Hope you like the answer.


Related Solutions

Could you please write a working program "linkedlist.cpp" using recursive approach for the given files below...
Could you please write a working program "linkedlist.cpp" using recursive approach for the given files below -------------------------------------------------------------------------------------------- // app.cpp #include <iostream> #include "linkedlist.h" using namespace std; void find(LinkedList& list, char ch) { if (list.find(ch)) cout << "found "; else cout << "did not find "; cout << ch << endl; } int main() { LinkedList list; list.add('x'); list.add('y'); list.add('z'); cout << list; find(list, 'y'); list.del('y'); cout << list; find(list, 'y'); list.del('x'); cout << list; find(list, 'y'); list.del('z'); cout << list;...
please using Repl.it basic C-programing part1 Write a program that requests 5 integers from the user...
please using Repl.it basic C-programing part1 Write a program that requests 5 integers from the user and stores them in an array. You may do this with either a for loop OR by getting a string from stdin and using sscanf to store formatted input in each spot in the array. part2 Add a function to the program, called get_mean that determines the mean, which is the average of the values. The function should be passed the array and the...
Java Programming Using the class below, please ), write a static method called parse that parses...
Java Programming Using the class below, please ), write a static method called parse that parses a String for balanced parentheses. we seek only to determine that the symbol ‘{‘ is balanced with ‘}’. parse accepts a single String parameter and returns an int. If parse returns a minus 1, then there are no errors, otherwise, parse should return the position within the String where an error occurred. For example parse(“{3 + {4/2} }”)   would return -1 parse(“{ { 4*X}”)...
Please do the following in JAVA. Deposit and Withdrawal Files Use Notepad or another text editor...
Please do the following in JAVA. Deposit and Withdrawal Files Use Notepad or another text editor to create a text file named Deposits.txt. The file should contain the following numbers, one per line: 100.00 124.00 78.92 37.55 Next, create a text file named Withdrawals.txt. The file should contain the following numbers, one per line: 29.88 110.00 27.52 50.00 12.90 The numbers in the Deposits.txt file are the amounts of deposits that were made to a savings account during the month,...
c-programing repl.it no advance this the instruction below do it as needed and put good comment...
c-programing repl.it no advance this the instruction below do it as needed and put good comment My Manual DNS (Domain Name Server) IPv4 internet addresses are of the form: AAA.BBB.CCC.DDD Where each letter represents a sectioned "subnet". Computers also have an associated hostname. For fun, you can find out your computer's hostname by opening a terminal and typing hostname. You are going to write a program that with a series of functions that perform actions based on this data. Goal...
Using Java Write the class RecursiveProbs, with the methods listed below. Write all the methods using...
Using Java Write the class RecursiveProbs, with the methods listed below. Write all the methods using recursion, NOT LOOPS. You may use JDK String Methods like substring() and length(), but do not use the JDK methods to avoid coding algorithms assigned. For example, don’t use String.revers(). public boolean recursiveContains(char c, String s) { if (s.length() == 0) return false; if (s.charAt(s.length() - 1) == c) return true; else return recursiveContains(c, s.substring(0, s.length() - 1)); } public boolean recursiveAllCharactersSame(String s) return...
Using files, Write a Java program to read 2 tutorials group of student id, assignment mark...
Using files, Write a Java program to read 2 tutorials group of student id, assignment mark (30), lab test mark(20) from 2 input files namely group1.txt and group 2.txt. Your program will calculate the total course work marks and write in to 3 output files with the following conditions: if the total course work marks are more than 40 out 50 write in to LIST1.TXT if the total course work marks are between 30 to 40 then write in to...
Edit question Write a program that merges two files as follows. The two files are in...
Edit question Write a program that merges two files as follows. The two files are in the docsharing which you can download it. One file will contain usernames(usernames.txt):foster001smith023nyuyen002...The other file will contain passwords(passwords.txt):x34rdf3ep43e4rddw32eds22...The program should create a third file matching username and passwords(usernamesPasswords.txt):foster001x34rdf3esmith023p43e4rddnyuyen002w32eds22......Give the user of your programs the option of displaying you output file. CAN ANYONE SOLVE THIS IN C
When using random access files in Java, the programmer is permitted to create files which can...
When using random access files in Java, the programmer is permitted to create files which can be read from and written to random locations. Assume that a file called "integers.dat" contains the following values: 25 8 700 284 63 12 50 Fill in blanks: You are required to write the following Java code statements: (a) create a new stream called, blueray, which allows the program to read from and write to the file, "integers.dat." _____________________ (b) Write a statement which...
THE QUESTION IS OF JAVA LANGUAGE. ANSWER IS REQUIRED IN THREE PARTS (THREE JAVA FILES). PLEASE...
THE QUESTION IS OF JAVA LANGUAGE. ANSWER IS REQUIRED IN THREE PARTS (THREE JAVA FILES). PLEASE DIFFERENTIATE FILES SO I CAN UNDERSTAND BETTER. NOTE - Submission in parts. Parts required - Dog Class Code, Dog Manager Class Code and the main code. Please differentiate all three in the answer. This Assignment is designed to take you through the process of creating basic classes, aggregation and manipulating arrays of objects. Scenario: A dog shelter would like a simple system to keep...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT