Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA (BABY NAME POPULARITY RANKING) The popularity ranking of baby names from years 2001 to 2010 is downloaded from www.ssa.gov/oact/babynames and stored in files named

JAVA (BABY NAME POPULARITY RANKING) The popularity ranking of baby names from years 2001 to 2010 is downloaded from www.ssa.gov/oact/babynames and stored in files named babynameranking2001.txt, babynameranking2002.txt, . . . , babynameranking2010.txt. You can download these files using Google Drive. Each file contains 1,000 lines. Each line contains a ranking, a boys name, number for the boys name, a girls name, and number for the girls name. For example, the first two lines in the file babynameranking2010.txt are as follows:

1 Jacob 21,875 Isabella 22,731

2 Ethan 17,866 Sophia 20,477

Therefore, the boys name Jacob and girls name Isabella are ranked #1 and the boys name Ethan and girls name Sophia are ranked #2; 21,875 boys are named Jacob, and 22,731 girls are named Isabella. Write a program that prompts the user to enter the year, gender, followed by a name, and displays the ranking of the name for the year. Your program should read the data directly from the files. Here are some sample runs:

image text in transcribed

Algorithm:

  1. Create two 2-dimensional arrays of String for boyNames and girlNames

private static String[][] boyNames = new String[10][1000];

private static String[][] girlNames = new String[10][1000];

  1. A method to read names

    1. For each year create the file name // for(int i=0; i

      1. Read each line

        1. Skip the ranking

        2. Read boys name

        3. Skip number of of boys name

        4. Read girls name

        5. Skip the number of girls name

  2. In main method

    1. readNames()

    2. Prompt the user for input

    3. Print the output

Enter the year: 2010 - Enter Enter the gender: M Enter Enter the name: Javier Enter Javier is ranked #190 in year 2010 Enter Enter Enter the year: 2010 Enter the gender: F Enter the name: ABC - Enter The name ABC is not ranked in year 2010

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

Step: 3

blur-text-image

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

Question

What does Disney do best to connect with its core consumers?

Answered: 1 week ago