This program is a Text File I/O example problem. This is a pretty beginner class
ID: 3843153 • Letter: T
Question
This program is a Text File I/O example problem. This is a pretty beginner class so we haven’t discussed any major topics. We are using abstract methods and exception handling to deal with this problem/ arrays and other basic java topics binary object files.I will include an example as reference to how much we have used. Essentially this is an excersie on Text File I/O
On Blackboard are two files named “BoyNames2015.txt” and “GirlNames2015.txt”. These files contain the 1,000 most popular boy and girl names in the United States in 2015, as compiled by the Social Security Administration. The files contain one line per name. Each line has a name, a blank, and the number of registered births using that name in 2015. Names are listed in descending order of popularity, so that the most popular name for the year appears at the top of the file.
Create a class named “NameAndBirths” with two instance variables, one a String containing a name, and one an int containing the number of registered births in 2015 for that name.
Write a program that reads the girl and boy files into memory using arrays of 1,000 NameAndBirths objects each (one for girls, one for boys). Then allow the user to input a name. The program should search through both arrays of NameAndBirths objects. If there is a match, then it should output the popularity ranking, the gender, and the number of registered births for that name and gender. The program should also indicate if there is no matching name entry.
For example, if the user enters the name “Justice,” then the program should output:
Justice is ranked 452 among girls with 696 registered births.
Justice is ranked 525 among boys with 543 registered births.
If the user enters the name “Benjamin,” then the program should output:
Benjamin is not ranked among the top 1000 girl names.
Benjamin is ranked 10 among boys with 13,608 registered births.
Submit the listings for the class containing main and the NameandBirths class, and a PrintScreen of the output when running your program using at least three names.
there are 1000 boy and girl names
BOY
FEMALE
EXAMPLE OF CODE NOT PART OF THE QUESTION FOR CONTEXT
Explanation / Answer
Here I have provided the two classes NameAndBirths and PopularityRanking, Popularity Ranking is the main class. Which takes the input of name and then it outputs the according to girls and boys data.
In popularity ranking please provide the path of file name in BOYS_FILE, GIRLS_FILE variable .
Code :
Output :
Enter name
Justice
Justice is ranked 452 among girls with 666 registered births.
Justice is ranked 525 among boys with 543 registered births.
Enter name
Noah
Noah is not ranked among the top 1000 girls names.
Noah is ranked 1 among boys with 19511 registered births.
Enter name
Benjamin
Benjamin is not ranked among the top 1000 girls names.
Benjamin is ranked 10 among boys with 13608 registered births.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.