Question: Use the data files from Programming Exercise 12.31 to write a program that enables the user to select a year, gender, and enter a name
Use the data files from Programming Exercise 12.31 to write a program that enables the user to select a year, gender, and enter a name to display the ranking of the name for the selected year and gender, as shown in Figure 21.9. To achieve the best efficiency, create two arrays for boy’s names and girl’s names, respectively. Each array has 10 elements for 10 years. Each element is a map that stores a name and its ranking in a pair with the name as the key.

Data from Programming Exercise 12.31
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 the URL such as http://liveexample.pearsoncmg.com/data/babynamesranking2001.txt. 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 babynameranking2010.txt are as follows: 1 Jacob 21,875 Isabella 22,731 2 Ethan 17,866 Sophia 20,477 Therefore, the boy’s name Jacob and girl’s name Isabella are ranked #1 and the boy’s name Ethan and girl’s 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 Web. Here are some sample runs:

Exercise21_11 Exercise21 11 A00 Eercise21.11 Select a year: 2004 Select a year: 2007 Select a year: 2001 Boy or girl? Male Boy or girt? Boy or girl? Female Fermale Enter a name Michael Enter a name: Michelle Enter a name: Samantha Find Ranking Find Ranking Find Ranking Boy name Michael is ranked #2 in year 2004 Giri name Michelle is ranked 94 in year 2007 Girl name Samantha is ranked 07 in year 2001
Step by Step Solution
3.53 Rating (170 Votes )
There are 3 Steps involved in it
import javanetURL import javautilHashMap import javautilMap import javautilScanner import javafxapplicationApplication import javafxgeometryPos import ... View full answer
Get step-by-step solutions from verified subject matter experts
