Fill This Form To Receive Instant Help
Homework answers / question archive / Given popular baby names by sex and ethnic group in 2011-2017
Given popular baby names by sex and ethnic group in 2011-2017. Data were collected through civil birth registration provided by DOHMH available owned by NYC OpenData. Write a Java program that sorting baby names in the descending order of frequency to represent the popularity of a name. Output the popular baby names by year of birth, gender and ethnic group requested by user.
Input:
Input file: “Popular_Baby_Names.csv”.
Data Dictionary:
Year of Birth: Year the baby was born
Sex: Sex of the baby
Ethnicity: Mother's Ethnicity
Baby's First Name: Baby's first names
Count: Number of babies with this name
User is prompted to enter year of birth, gender, and ethnicity in console.
Output:
Output all the baby names by year of birth, gender, ethnic group requested by user in the order of popularity.
For instance,
Popular baby boy name in hispanic in 2017:
Liam, Jacob, Dylan, Matthew, Noah, Sebastian, Jayden, Lucas, Ethan, Aaron, …………
Requirements:
No third-party libraries are allowed.
You may add Java code in the main method but do not modify the existed statements in HW4.java file.
You may use BufferedReader, Scanner …… to read the input file. To parse a string, you may refer to the Java StringTokenizer class or String class.
Classes required for the project:
Your Java program must be submitted on Blackboard as attachments. NO .class files.
Any submissions that do not compile or work; or classes do not name as required above will receive a 0. Excuses such as “It compiled on my computer” or “It worked last time” will not be accepted. Your program must work on all machines not just yours.
import java.util.Scanner; public class Hw4 { public static void main(String[] args) { boolean done = false; while (!done) { System.out.print("Year of Birth(2011-2017, yyyy): "); Scanner in = new Scanner(System.in); int year = in.nextInt(); System.out.print("Gender(boy/girl): "); in = new Scanner(System.in); String gender = in.nextLine(); System.out.print("Ethnicity(asian/black/hispanic/white): "); in = new Scanner(System.in); String ethnicity = in.nextLine(); // closing scanner in.close(); System.out.println("Popular baby " + gender +" names in " + ethnicity + " in " + year +":"); //add code to print out the popular baby names by year of birth, gender and ethnic group System.out.print("Interested in more(yes/no): "); in = new Scanner(System.in); String more = in.nextLine(); if (more.equalsIgnoreCase("no")) done = true; } } }