Menu

[Solved]Baby Name Popularity Ranking Popularity Ranking Baby Names Years 2008 2017 Downloaded Wwws Q37129807

(Baby name popularity ranking) The popularity ranking of babynames from years 2008
to 2017 can be downloaded from www.ssa.gov/oact/babynames andstored in files
named babynameranking2008.txt, babynameranking2009.txt, . . .,
babynameranking2017.txt. You can download these from Google Drive.Each file
contains 1,000 lines. Each line contains a ranking, a boy’s name,number for the boy’s
name, a girl’s name, and number for the girl’s name. For example,the first two lines in
the file babynameranking2017.txt are as follows:
1 Liam 18,728 Emma 19,738
2 Noah 18,326 Olivia 18,632
Write a program that enables the user to select a year, gender, andenter a name to
display the ranking of the name for the selected year and gender,as shown below. To
achieve the best efficiency, create two arrays for boy’s names andgirl’s names,
respectively. Each array has 10 elements for 10 years. Each elementis a map that
stores a name and its ranking in a pair with the name as thekey.
Enter a year: 2016
Boy or Girl? Boy
Enter a name: Liam
Boy name Liam is ranked #2 in 2017

Enter a year: 2011
Boy or Girl? Girl
Enter a name: Hannah
Girl name Hannah is ranked #25 in 2011

import java.io.*;
import java.util.*;
public class Lab08{
@SuppressWarnings("unchecked")
private static Map<String, Integer>[] boys = newHashMap[10];
@SuppressWarnings("unchecked")
private static Map<String, Integer>[] girls = newHashMap[10];
public static void main(String[] args) throws IOException {
Scanner input = new Scanner(System.in);
String answer;
readNames(); // method to read the info from the files and add toour Map array

// Get user input and continue until done

do {
System.out.print("ENter a year (2008-2017):");
int year = input.nextInt();input.nextLine();
System.out.print("Boy or girl? ");
String sex = input.nextLine().toLowerCase();
System.out.print("ENter a name: ");
String name = input.nextLine();
switch (sex) {
// display the output based on the sex (boy or girl)
}
System.out.print("Do you want check another name (yes orno)?");
answer = input.nextLine().toLowerCase();
} while (answer.equals("yes"));
} // end main

//read information from each file and add to appropriate Maparray
public static void readNames() throws IOException {
File infile;
for(int i=0;i<10;++i) {
boys[i] = new HashMap<>();
girls[i] = new HashMap<>();
}

for(int i=0;i<=9;++i) {
// construct the file name

String filename = // construct the file name ;
infile = new File(filename);
Scanner in = new Scanner(infile);
while(in.hasNext()) {
// read info from the file and add to Map arrays
} // end while
in.close();
} // end for loop
} // end readNames()

https://drive.google.com/file/d/1-CWbhvVKRkeUv41AmhC0Iq0DqjIeZFPG/view?usp=sharing

https://drive.google.com/file/d/14tczIYuzBWIUzEPzwaax2R88qAjjmRSg/view?usp=sharing

https://drive.google.com/file/d/1X08tC70txCkHAoKHefUp2JwvMmFt-BcL/view?usp=sharing

https://drive.google.com/file/d/1ICLJd0brEE_FqbdEg8mmdqkMQJb1uH88/view?usp=sharing

https://drive.google.com/file/d/1WETQvyHHnlVjxmazn3ObFhibd75TtN1G/view?usp=sharing

https://drive.google.com/file/d/1qkV-hegyOSMCCV4f9Ck5jzE4frZ8cIuh/view?usp=sharing

https://drive.google.com/file/d/1Yfvk3ULBdbsPz0OQIACXuMB-4E2agng2/view?usp=sharing

https://drive.google.com/file/d/19M_B1pvqateXd2dgKQziM1tZ9U64aM2B/view?usp=sharing

https://drive.google.com/file/d/1Gxntd3aBC6m89zaEfynN2hiVA0KZwoDJ/view?usp=sharing

https://drive.google.com/file/d/1PsK7-Kl8Q_F0NN3R0BXU3dsFNV75F3sv/view?usp=sharing

Expert Answer


Answer to (Baby name popularity ranking) The popularity ranking of baby names from years 2008 to 2017 can be downloaded from www.s… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *