Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Java) BabyName and BabyNameData NEW ANSWER PLEASE (OTHER SIMILAR ONES AREN'T THE SAME) For this problem, you will use data from the U.S. Social Security

(Java) BabyName and BabyNameData NEW ANSWER PLEASE (OTHER SIMILAR ONES AREN'T THE SAME)

For this problem, you will use data from the U.S. Social Security Administration to analyze the most popular baby names in the U.S. in a particular year. Implement 2 classes:

BabyName, which represents a baby name with all of its data. Use this template: BabyName.javaDownload BabyName.java

BabyNameData, which reads in a file of data and provides some analysis on the dataset. Use this template: BabyNameData.javaDownload BabyNameData.java

You can assume all data files will be in the proper format (as exemplified by the sample file in the example below). Specifically, each line in the file contains the rank, boy name, boy name count, boy name percentage, girl name, girl name count, and girl name percentage. For example, in babynames1.txt Download babynames1.txt, the #1 boy name is Michael with a count of 462,085 and a percentage of 2.2506, and the #1 girl name is Jessica with a count of 302,962 and a percentage of 1.5436.

You must catch any FileNotFoundException that is thrown and print out a message in the format: "File: [filename] not found", e.g., File: lines.txt not found

Example: BabyNameData data = new BabyNameData("babynames1.txt Download babynames1.txt"); data.getAllGirlNames(); // returns a list containing: [Jessica, Ashley, Emily, Sarah, Samantha, Amanda, Brittany, Elizabeth, Taylor, Megan] data.getAllBoyNames(); // returns a list containing: [Michael, Christopher, Matthew, Joshua, Jacob, Nicholas, Andrew, Daniel, Tyler, Joseph] data.getAllNonGenderSpecificNames(); // returns an empty list data.getGirlNameAtRank(3); // returns "Emily" data.getBoyNameAtRank(3); // returns "Matthew" BabyName.java: /** * A name in a list of baby names */ public class BabyName { // ADD YOUR INSTANCE VARIABLES HERE /** * Constructor * * @param name the name * @param rank rank compared to other names * @param count how many babies with this name born * @param percent percent of babies with this name born */ public BabyName(String name, int rank, int count, double percent) { // FILL IN } public String getName() { return ""; // FIX ME } public int getRank() { return -1; // FIX ME } public int getCount() { return -1; // FIX ME } public double getPercent() { return -1.0; // FIX ME } } BabyNameData.java:

import java.util.*; /** * A set of baby name data ranking the most popular baby names in the U.S. in a * particular year */ public class BabyNameData { // ADD YOUR INSTANCE VARIABLES HERE /** * Constructor that creates this object with data from a file * * @param babyNamesFileName name of input file */ public BabyNameData(String babyNamesFileName) { // FILL IN } /** * * @return all girl names (in a non-specific order) */ public List getAllGirlNames() { return null; // FIX ME } /** * * @return all boy names (in a non-specific order) */ public List getAllBoyNames() { return null; // FIX ME } /** * * @return all names that appear in the data for both boys and girls (in a * non-specific order) */ public List getAllNonGenderSpecificNames() { return null; // FIX ME } /** * * @param rank * @return the girl name at the rank specified * * If rank is out of the range of data, throw an * IllegalArgumentException with the message "Rank [rank] out of range * of data"

*/ public String getGirlNameAtRank(int rank) throws IllegalArgumentException { return ""; // FIX ME } /** * * @param rank * @return the boy name at the rank specified * * If rank is out of the range of data, throw an * IllegalArgumentException with the message "Rank [rank] out of range * of data" */ public String getBoyNameAtRank(int rank) { return ""; // FIX ME } } BabyNames.txt: 1 Michael 462085 2.2506 Jessica 302962 1.5436 2 Christopher 361250 1.7595 Ashley 301702 1.5372 3 Matthew 351477 1.7119 Emily 237133 1.2082 4 Joshua 328955 1.6022 Sarah 224000 1.1413 5 Jacob 298016 1.4515 Samantha 223913 1.1408 6 Nicholas 275222 1.3405 Amanda 190901 0.9726 7 Andrew 272600 1.3277 Brittany 190779 0.9720 8 Daniel 271734 1.3235 Elizabeth 172383 0.8783 9 Tyler 262218 1.2771 Taylor 168977 0.8609 10 Joseph 260365 1.2681 Megan 160312 0.8168

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

More Books

Students also viewed these Databases questions