Question
Project Details: Design and implement a program that analyses baby name popularities in data provided by the Social Security Administration. Every 10 years, the data
Project Details:
Design and implement a program that analyses baby name popularities in data provided by the Social Security Administration. Every 10 years, the data gives the 1000 most popular boy and girl names for kids born in the US. The data can be boiled down to a single text file as shown below. On each line we have the name, followed by the rank of that name in 1900, 1910, 1920, ... 2000 (11 numbers). A rank of 1 was the most popular name that year, while a rank of 997 was not very popular. A 0 means the name did not appear in the top 1000 that year at all. The elements on each line are separated from each other by a single space. The lines are in alphabetical order, although we will not depend on that.
Sam 58 69 99 131 168 236 278 380 467 408 466
Samantha 0 0 0 0 0 0 272 107 26 5 7
Samara 0 0 0 0 0 0 0 0 0 0 886
Samir 0 0 0 0 0 0 0 0 920 0 798
Sammie 537 545 351 325 333 396 565 772 930 0 0
Sammy 0 887 544 299 202 262 321 395 575 639 755
Samson 0 0 0 0 0 0 0 0 0 0 915
Samuel 31 41 46 60 61 71 83 61 52 35 28
Sandi 0 0 0 0 704 864 621 695 0 0 0
Sandra 0 942 606 50 6 12 11 39 94 168 257
This file, called name_data.txt, is available on Canvas. Reference the file in your code.
Classes Required:
NameRecord encapsulates the data for one name: the name and its rank over the years. This is essentially the data of one line from the file shown above. Use an int array to store the int rank numbers. The NameRecord constants START=1900 and DECADES=11 define the start year and the number of decades in the data. Methods:
o Constructor takes a String line as in the file above and sets up the NameRecord object.
o String getName() returns the name
o int getRank(int decade) returns the rank of the name in the given decade. Use the convention that decade=0 is 1900, decade=1 is 1910, and so on.
o int bestYear() returns the year where the name was most popular, using the earliest year in the event of a tie. Looking at the data above Samir's best year is 2000, while Sandra's best year is 1940. Returns the actual year, for example 1920, so the caller does not need to adjust for START. It is safe to assume that no rank in the data is ever larger than 1100, and every name has at least one year with a non-zero rank.
o void plot() uses the StdDraw class to plot the popularity of the name over the 11 decades in a random color. Available colors are BLACK, BLUE, CYAN, DARK_GRAY, GRAY, GREEN, LIGHT_GRAY, MAGENTA, ORANGE, PINK, RED, WHITE, YELLOW. Scale point coordinates to be between 0 and 1, assuming that no rank is ever larger than 1100, and remembering that a rank of 1 should be on top of the image, while a rank of 1000 should be on the bottom.
NameSurfer the driver. The main method should read all the data from the file and store it in an array of NameRecord objects. It should then offer the following menu to the user:
1 Find best year for a name
2 Find best rank for a name
3 Plot popularity of a name
4 Clear plot
5 Quit
Enter your selection.
If 1, 2, or 3 is entered, the program should prompt the user for a name, search for that name in the array, print (or plot) the desired information, and display the menu again. If the name is not found in the array (search should ignore case) print an error message and display the menu again. If 4 is entered, clear the plot by calling StdDraw.clear(); The program quits only when the plot window is closed.
Remember to keep your objects encapsulated.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started