Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.The user can get a bar chart (produced using text characters) of the historical popularity of a name in a state over a period of

1.The user can get a bar chart (produced using text characters) of the historical popularity of a name in a state over a period of time. Each bar is one character in width; use one bar for each year within the time period. The program also shows the years when the name was most and least popular during that time period, and the counts of the name during those years. Note that the name is not gender-specic here, so the program should include counts from both genders. Here are two examples of what the programs output might look like:

Historical Trends for Stacy in TN, 1950-2015 . . . .... . .... ..

..... . ......... ......... ............ .............. .............. .

................... . ..................... ........................ ..........

.................. . .................................. . .

-----------------------------------------------------------------

Most popular in 1971 (274)

Least popular in 1950 (0)

2. The user can get a list of the top 10 names for a given state, year, and gender. The programs output shows a list of these names along with their individual counts. For example, asking for the top 10 male names in TN for 1995 should produce something like this: Top 10 Male Names in TN for 1995

1. Austin 804

2. Jacob 786

3. William 767

4. James 764

5. Joshua 757

6. Christopher 750

7. Michael 747

8. Matthew 708

9. Brandon 705 1

10. John 618

3. The program performs input validation on all user inputs. This means that every input must be checked to ensure that it makes sense; if not, an appropriate error message should be shown and a loop should allow the user to re-enter the input as many times as necessary. Input validation should include (but is not limited to): Ensuring that any input for a state is a valid postal code Ensuring that any input for year is consistent with the data (i.e., within the range 1910-2018) Ensuring that any input for gender is consistent with the data (i.e., F or M) Ensuring that the end year cannot be before the start year when looking at historical trends We havent discussed how to verify the data type of input, so dont worry about that. You can assume that user input will be of the correct type, but you still need to check its value. 4. (5 pts) The program runs repeatedly until the user indicates they want to exit.

*Provide code

public class WhatsInAName { public static void main(String[] args) { // Here's an example of how to call the readData method for the TN data file String[][] data = readData("TN");

// At this point, the 2D array data contains all the information from the file. // The commas in the file are just used as delimiters; they are not included // in the data array. All elements of the array are strings. // // For example, the first line of the file is: // TN,F,1910,Mary,735 // // Thus, in the array: // data[0][0] is "TN" // data[0][1] is "F" // data[0][2] is "1910" // data[0][3] is "Mary" // data[0][4] is "735" // }

// Reads data from file for the specified state code. Returns the data // as a 2D array of strings. public static String[][] readData(String stateCode) { ArrayList data = new ArrayList(); try { Scanner f = new Scanner(new FileReader(stateCode + ".TXT")); while (f.hasNext()) { data.add(f.nextLine().split(",")); } f.close(); return data.toArray(new String[][]{{}}); } catch (FileNotFoundException e) { return null; } } }

*Provide text file

TN,F,1910,Mary,735 TN,F,1910,Ruby,168 TN,F,1910,Annie,163 TN,F,1910,Ruth,163 TN,F,1910,Elizabeth,154 TN,F,1910,Louise,151 TN,F,1910,Margaret,149 TN,F,1910,Willie,147 TN,F,1910,Ethel,133 TN,F,1910,Lillie,129 TN,F,1910,Gladys,125

image text in transcribedimage text in transcribedimage text in transcribed

Project Description.pdf x + O O file:///C:/Users/mydan/Downloads/Project%20Description. * * - + SD A h a 8 The popularity of human names varies quite a bit over time. In the United States, the Social Security Administration (SSA) maintain statistics on names. In this project, you'll be writing software that analyzes files of SSA data containing the historical popularity of various first names. Based on this information, the user can see popularity trends for a specific name over a period of time, or see the top names during a certain year. The project starter code contains 51 text data files!: one for each state, plus one for the District of Columbia. Fach file contains name data from 1910 to 2018 and is named according to the state's two-letter postal code (for example, TN.TXT). Each line of each file is formatted like this: TN.F.2018, Savannah,122 This line means that in 2018, there were 122 female newborns named Savannah in Tennessee registered with the SSA. Fach file is sorted by gender (F before M), then by year in ascending order, then by name count in descending order, then by name in alphabetical order. The starter code includes a method, readData, in Whats in Nano, java that reads a data file for a specific state and returns a 2D array of strings containing the contents. The main method contains an example of how to call this method. We haven't covered how to read from files in this class, so leave readData unchanged you can just call it is needed. Specifications Complete the Whatsiname program to the following specifications: 1. (75 pts) The user can get a bar "chart" (produced using text characters) of the historical popularity of a name in a state over a period of time. Each bar is one character in width; use one bar for each year within the time period. The program also shows the years when the tune wis most and least popular during that time period, and the counts of the name during them yours. Note that the https://catalog.data.gov/dataset/baby- frescial security card applications databy-state-and-district 12:19 AM 4 ENG 5/2/2020 - + Least popular in 1941 (24) ED A h a B 2. (25 pts) The user can get a list of the top 10 names for a given state, year, and gender. The program's output shows a list of these names along with their individual counts. For example, asking for the top 10 male names in TN for 1995 should produce something like this: Top 10 Male Names in TN for 1995 Austin 804 Jacob 786 William 767 James 764 Joshua 757 Christopher 750 Michael 747 Matthew Brandon John TOB 705 618 10. 3. (45 pts) The program performs input validation on all user inputs. This means that every input must be checked to ensure that it makes sense, if not, an appropriate error message should be shown and a loop should allow the user to re-enter the input as many times as necessary. Input validation should include but is not limited to): Ensuring that any input for a state is a valid postal code Ensuring that any input for year is consistent with the data (Le., within the range 1910 2018) Ensuring that any input for gender is consistent with the data (ie, For M) suring that the end year cannot be before the start year when looking at historical trend - .. 12:19 AM A N G 12/2020 + DD A h 8 8. 9. 10. Matthew Brandon John 708 705 618 3. (45 pts) The program performs input validation on all user inputs. This means that every input must be checked to ensure that it makes sense if not, an appropriate error message should be shown and a loop should allow the user to re-enter the input as many times as necessary. Input validation should include (but is not limited to: Ensuring that my input for a state is a vlid postal code Ensuring that any input for year is consistent with the data (ie, within the range 1910-2018) Ensuring that any input for gender is consistent with the data (e., F or M) Ensuring that the end year cannot be before the start year when looking at historical trends We haven't discussed how to verify the data type of input, so don't worry about that. You can assume that user input will be of the correct type, but you still need to check its value. 4. (5 pts) The program runs repeatedly until the user indicates they want to exit. Other Considerations Break down your code into methods so that you can focus on manable chunks. I'm leaving the details of how to r e your code up to you, but please don't turn in a single main method with several hundred lines of code in it :) . I will show a working version of the project in l. Your program's output format does not need to match mine exactly, as long as you meet the specifications above . All data analysis for this project must be done using the 2D string array returned from readData. There are better ways to proces the data using more advanced structures such as maps or dictio maries, but I'm intentionally limiting the project scope to what we've covered this semester. Programming hints that might come in handy: - Using canner's nextInt and nextLine methods sequentially can result in some unexpected Declandes mar chant 12:19 AM Aw40 ENG 5/2/2020 Project Description.pdf x + O O file:///C:/Users/mydan/Downloads/Project%20Description. * * - + SD A h a 8 The popularity of human names varies quite a bit over time. In the United States, the Social Security Administration (SSA) maintain statistics on names. In this project, you'll be writing software that analyzes files of SSA data containing the historical popularity of various first names. Based on this information, the user can see popularity trends for a specific name over a period of time, or see the top names during a certain year. The project starter code contains 51 text data files!: one for each state, plus one for the District of Columbia. Fach file contains name data from 1910 to 2018 and is named according to the state's two-letter postal code (for example, TN.TXT). Each line of each file is formatted like this: TN.F.2018, Savannah,122 This line means that in 2018, there were 122 female newborns named Savannah in Tennessee registered with the SSA. Fach file is sorted by gender (F before M), then by year in ascending order, then by name count in descending order, then by name in alphabetical order. The starter code includes a method, readData, in Whats in Nano, java that reads a data file for a specific state and returns a 2D array of strings containing the contents. The main method contains an example of how to call this method. We haven't covered how to read from files in this class, so leave readData unchanged you can just call it is needed. Specifications Complete the Whatsiname program to the following specifications: 1. (75 pts) The user can get a bar "chart" (produced using text characters) of the historical popularity of a name in a state over a period of time. Each bar is one character in width; use one bar for each year within the time period. The program also shows the years when the tune wis most and least popular during that time period, and the counts of the name during them yours. Note that the https://catalog.data.gov/dataset/baby- frescial security card applications databy-state-and-district 12:19 AM 4 ENG 5/2/2020 - + Least popular in 1941 (24) ED A h a B 2. (25 pts) The user can get a list of the top 10 names for a given state, year, and gender. The program's output shows a list of these names along with their individual counts. For example, asking for the top 10 male names in TN for 1995 should produce something like this: Top 10 Male Names in TN for 1995 Austin 804 Jacob 786 William 767 James 764 Joshua 757 Christopher 750 Michael 747 Matthew Brandon John TOB 705 618 10. 3. (45 pts) The program performs input validation on all user inputs. This means that every input must be checked to ensure that it makes sense, if not, an appropriate error message should be shown and a loop should allow the user to re-enter the input as many times as necessary. Input validation should include but is not limited to): Ensuring that any input for a state is a valid postal code Ensuring that any input for year is consistent with the data (Le., within the range 1910 2018) Ensuring that any input for gender is consistent with the data (ie, For M) suring that the end year cannot be before the start year when looking at historical trend - .. 12:19 AM A N G 12/2020 + DD A h 8 8. 9. 10. Matthew Brandon John 708 705 618 3. (45 pts) The program performs input validation on all user inputs. This means that every input must be checked to ensure that it makes sense if not, an appropriate error message should be shown and a loop should allow the user to re-enter the input as many times as necessary. Input validation should include (but is not limited to: Ensuring that my input for a state is a vlid postal code Ensuring that any input for year is consistent with the data (ie, within the range 1910-2018) Ensuring that any input for gender is consistent with the data (e., F or M) Ensuring that the end year cannot be before the start year when looking at historical trends We haven't discussed how to verify the data type of input, so don't worry about that. You can assume that user input will be of the correct type, but you still need to check its value. 4. (5 pts) The program runs repeatedly until the user indicates they want to exit. Other Considerations Break down your code into methods so that you can focus on manable chunks. I'm leaving the details of how to r e your code up to you, but please don't turn in a single main method with several hundred lines of code in it :) . I will show a working version of the project in l. Your program's output format does not need to match mine exactly, as long as you meet the specifications above . All data analysis for this project must be done using the 2D string array returned from readData. There are better ways to proces the data using more advanced structures such as maps or dictio maries, but I'm intentionally limiting the project scope to what we've covered this semester. Programming hints that might come in handy: - Using canner's nextInt and nextLine methods sequentially can result in some unexpected Declandes mar chant 12:19 AM Aw40 ENG 5/2/2020

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Accounting questions