Question

Objective The Final Project aims to demonstrate your ability to analyze data from a big database,...

Objective
The Final Project aims to demonstrate your ability to analyze data from a big database, exercise use of arrays of objects, external classes, processing files and user interaction. For this project, you will design and implement a program that analyzes baby name popularities in data provided by the Social Security Administration.

Every 10 years, the data gives the 1,000 most popular boy and girl names for kids born in the United States. 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 1,000 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
...

The complete file is available through the name_data.txt link.

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:

Constructor—takes a String line as in the file above and sets up the NameRecord object.

String getName()—returns the name.

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.

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.

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, and YELLOW. You can scale the coordinate system appropriately, 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. The StdDraw class can be downloaded. Documentation can be found online as well.

NameSurfer—the driver. The main method should read all of 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 the best year for a name

2 – Find the best rank for a name

3 – Plot the popularity of a name

4 – Clear the 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 the 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.

NOTE: Remember to keep your objects encapsulated.

Formatting Requirements

Follow indentation rules as discussed in class.

Use descriptive variable names.

Comment your code: Your name, name of the class and assignment at the beginning of program, and description of program functionality at the beginning of program. Every method should have a comment with a short description on top. Every instance variable should be followed by a comment that describes it on the same line.


Assessment
Evaluation of project success will be determined by the following criteria:

NameRecord class has the correct instance variables and constants

NameRecord constructor is implemented correctly

getName is implemented correctly

getRank is implemented correctly

bestYear is implemented correctly

plot is implemented correctly

driver correctly reads data from name_data.txt and stores it in array

driver prints user menu and reads user’s option

search for name is performed correctly

option 1 is handled correctly

option 2 is handled correctly

option 3 is handled correctly

option 4 is handled correctly

option 5 is handled correctly

Homework Answers

Answer #1

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public category sound unit association guide = null;

   public DB() catch (ClassNotFoundException e)
   }

   public ResultSet runSql(String sql) throws SQLException {
       Statement sta = guide.createStatement();
       return sta.executeQuery(sql);
   }

   public mathematician runSql2(String sql) throws SQLException {
       Statement sta = guide.createStatement();
       return sta.execute(sql);
   }

   @Override
   protected void finalize() throws Throwable !conn.isClosed()) {
           conn.close();
      
   }
}
4). produce a category with name "Main" which can be our crawler.

import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;


public category Main {
   public static sound unit sound unit = new DB();

   public static void main(String[] args) throws SQLException, IOException URL is already in info
       String sql = "select * from Record wherever computer address = '"+URL+"'";
       ResultSet rs = sound unit.runSql(sql);
       if(rs.next())else{
           //store the computer address to info to avoid parsing once more
           sql = "INSERT INTO `Crawler`.`Record` " + "(`URL`) VALUES " + "(?);";
           PreparedStatement stmt = sound unit.conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
           stmt.setString(1, URL);
           stmt.execute();

           //get helpful info
           Document doc = Jsoup.connect("http://www.mit.edu/").get();

           if(doc.text().contains("research"))

           //get all links and recursively decision the processPage methodology
   components queries = doc.select("a[href]");
           for(Element link: questions)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. Consider the following interface: interface Duty { public String getDuty(); } a. Write a class...
1. Consider the following interface: interface Duty { public String getDuty(); } a. Write a class called Student which implements Duty. Class Student adds 1 data field, id, and 2 methods, getId and setId, along with a 1-argument constructor. The duty of a Student is to study 40 hours a week. b. Write a class called Professor which implements Duty. Class Professor adds 1 data field, name, and 2 methods, getName and setName, along with a 1-argument constructor. The duty...
IN JAVA Iterative Linear Search, Recursive Binary Search, and Recursive Selection Sort: <-- (I need the...
IN JAVA Iterative Linear Search, Recursive Binary Search, and Recursive Selection Sort: <-- (I need the code to be written with these) I need Class river, Class CTRiver and Class Driver with comments so I can learn and better understand the code I also need a UML Diagram HELP Please! Class River describes river’s name and its length in miles. It provides accessor methods (getters) for both variables, toString() method that returns String representation of the river, and method isLong()...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...
I need this before the end of the day please :) In Java 10.13 Lab 10...
I need this before the end of the day please :) In Java 10.13 Lab 10 Lab 10 This program reads times of runners in a race from a file and puts them into an array. It then displays how many people ran the race, it lists all of the times, and if finds the average time and the fastest time. In BlueJ create a project called Lab10 Create a class called Main Delete what is in the class you...
In Chapter 9, you created a Contestant class for the Greenville Idol competition. The class includes...
In Chapter 9, you created a Contestant class for the Greenville Idol competition. The class includes a contestant’s name, talent code, and talent description. The competition has become so popular that separate contests with differing entry fees have been established for children, teenagers, and adults. Modify the Contestant class to contain a field that holds the entry fee for each category, and add get and set accessors. Extend the Contestant class to create three subclasses: ChildContestant, TeenContestant, and AdultContestant. Child...
Finish the CustomerAccountTransactions program that reads customer accounts receivable data from a file and then applies...
Finish the CustomerAccountTransactions program that reads customer accounts receivable data from a file and then applies a series of transactions to the accounts. Its main() method uses the CustomerAccounts class to manage a collection of CustomerAccount objects: reading customer accounts data & transactions, and obtaining a String showing the customer accounts data after the operations are complete. You will need to complete the readCustomerAccounts () and applyTransactions() methods in the CustomerAccounts class. First, please fill in your name in the...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do depending upon what the user enters, please refer to the examples below to use to test your program. Run your final program one time for each scenario to make sure that you get the expected output. Be sure to format the output of your program so that it follows what is included in the examples. Remember, in all examples bold items are entered by...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT