Project Details: JAVA Design and implement a program that analyses baby name popularities in data provided by the Social
Posted: Tue Jul 12, 2022 8:28 am
Project Details: JAVA
Design and implement a program that analyses baby namepopularities in data provided by the Social SecurityAdministration. Every 10 years, the data gives the 1000 mostpopular boy and girl names for kids born in the US. The data can beboiled down to a single text file as shown below. On each line wehave the name, followed by the rank of that name in 1900, 1910,1920, ... 2000 (11 numbers). A rank of 1 was the most popular namethat year, while a rank of 997 was not very popular. A 0 means thename did not appear in the top 1000 that year at all. The elementson each line are separated from each other by a single space. Thelines are in alphabetical order, although we will not depend onthat.
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 andits rank over the years. This is essentially the data of one linefrom the file shown above. Use an int array to store the int ranknumbers. The NameRecord constants START=1900 and DECADES=11 definethe start year and the number of decades in the data. Methods:
o Constructor – takes a String line as in the file above andsets up the NameRecord object.
o String getName() – returns the name
o int getRank(int decade) – returns the rank of the name in thegiven decade. Use the convention that decade=0 is 1900, decade=1 is1910, and so on.
o int bestYear() – returns the year where the name was mostpopular, using the earliest year in the event of a tie. Looking atthe data above Samir's best year is 2000, while Sandra's best yearis 1940. Returns the actual year, for example 1920, so the callerdoes not need to adjust for START. It is safe to assume that norank in the data is ever larger than 1100, and every name has atleast one year with a non-zero rank.
o void plot() – uses the StdDraw class to plot the popularity ofthe name over the 11 decades in a random color. Available colorsare BLACK, BLUE, CYAN, DARK_GRAY, GRAY, GREEN, LIGHT_GRAY, MAGENTA,ORANGE, PINK, RED, WHITE, YELLOW. Scale point coordinates to bebetween 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 thedata 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 fora name, search for that name in the array, print (or plot) thedesired information, and display the menu again. If the name is notfound in the array (search should ignore case) print an errormessage and display the menu again. If 4 is entered, clear the plotby calling StdDraw.clear(); The program quits only when the plotwindow is closed.
Remember to keep your objects encapsulated.
Design and implement a program that analyses baby namepopularities in data provided by the Social SecurityAdministration. Every 10 years, the data gives the 1000 mostpopular boy and girl names for kids born in the US. The data can beboiled down to a single text file as shown below. On each line wehave the name, followed by the rank of that name in 1900, 1910,1920, ... 2000 (11 numbers). A rank of 1 was the most popular namethat year, while a rank of 997 was not very popular. A 0 means thename did not appear in the top 1000 that year at all. The elementson each line are separated from each other by a single space. Thelines are in alphabetical order, although we will not depend onthat.
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 andits rank over the years. This is essentially the data of one linefrom the file shown above. Use an int array to store the int ranknumbers. The NameRecord constants START=1900 and DECADES=11 definethe start year and the number of decades in the data. Methods:
o Constructor – takes a String line as in the file above andsets up the NameRecord object.
o String getName() – returns the name
o int getRank(int decade) – returns the rank of the name in thegiven decade. Use the convention that decade=0 is 1900, decade=1 is1910, and so on.
o int bestYear() – returns the year where the name was mostpopular, using the earliest year in the event of a tie. Looking atthe data above Samir's best year is 2000, while Sandra's best yearis 1940. Returns the actual year, for example 1920, so the callerdoes not need to adjust for START. It is safe to assume that norank in the data is ever larger than 1100, and every name has atleast one year with a non-zero rank.
o void plot() – uses the StdDraw class to plot the popularity ofthe name over the 11 decades in a random color. Available colorsare BLACK, BLUE, CYAN, DARK_GRAY, GRAY, GREEN, LIGHT_GRAY, MAGENTA,ORANGE, PINK, RED, WHITE, YELLOW. Scale point coordinates to bebetween 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 thedata 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 fora name, search for that name in the array, print (or plot) thedesired information, and display the menu again. If the name is notfound in the array (search should ignore case) print an errormessage and display the menu again. If 4 is entered, clear the plotby calling StdDraw.clear(); The program quits only when the plotwindow is closed.
Remember to keep your objects encapsulated.