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
Play musical chords (JAVA PROGRAMMING) Notes and frequencies Every musical note has a name and a...
Play musical chords (JAVA PROGRAMMING) Notes and frequencies Every musical note has a name and a frequency. You are given a file where each line contains a note name, a tab character, and a frequence, which is a floating point value. For example, here are the first few lines from the file notes_frequencies.txt: A0 27.5 A#0 29.1353 B0 30.8677 C1 32.7032 C#1 34.6479 D1 36.7081 D#1 38.8909 E1 41.2035 F1 43.6536 Playing chords Write a program named PlayChords that first...
The project CreateDirectoriesDemo is included with the files for this chapter as a zipped file. rewrite...
The project CreateDirectoriesDemo is included with the files for this chapter as a zipped file. rewrite the program so that it asks the user for the location where the new directories are to be created, and then asks the user to enter, one at a time, the relative path names of the directories it should create. Amended additional details to the above abstraction of the requirements. The application should be multiplatform adaptive. This means that it should work on an...
#include<iostream> #include<iomanip> using namespace std; int main() { //variables int choice; float radius,base,height,area; const double PI=3.14159;...
#include<iostream> #include<iomanip> using namespace std; int main() { //variables int choice; float radius,base,height,area; const double PI=3.14159; //repeat until user wants to quits while(true) { //menu cout<<endl<<endl<<"Geometry Calculator"<<endl<<endl; cout<<"1. Calculate the area of a circle"<<endl; cout<<"2. Calculate the area of a triangle"<<endl; cout<<"3. Quit"<<endl<<endl; //prompt for choice cout<<"Enter your choice(1-3): "; cin>>choice; cout<<endl; //if choice is circle if(choice==1) { cout<<"What is the radius of the circle? "; cin>>radius; //calculating area area=PI*radius*radius; cout<<endl<<"The area of the circle is "<<fixed<<setprecision(3)<<area<<endl; } //if choice...
Write a Java class called CityDistances in a class file called CityDistances.java.    2. Your methods...
Write a Java class called CityDistances in a class file called CityDistances.java.    2. Your methods will make use of two text files. a. The first text file contains the names of cities. However, the first line of the file is a number specifying how many city names are contained within the file. For example, 5 Dallas Houston Austin Nacogdoches El Paso b. The second text file contains the distances between the cities in the file described above. This file...
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()...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):         self.name = name         self.pop = pop         self.area = area         self.continent = continent     def getName(self):         return self.name     def getPopulation(self):         return self.pop     def getArea(self):         return self.area     def getContinent(self):         return self.continent     def setPopulation(self, pop):         self.pop = pop     def setArea(self, area):         self.area = area     def setContinent(self, continent):         self.continent = continent     def __repr__(self):         return (f'{self.name} (pop:{self.pop}, size: {self.area}) in {self.continent} ') TASK 2 Python Program: File: catalogue.py from Country...
Objective: Write a Java program that will use a JComboBox from which the user will select...
Objective: Write a Java program that will use a JComboBox from which the user will select to convert a temperature from either Celsius to Fahrenheit, or Fahrenheit to Celsius. The user will enter a temperature in a text field from which the conversion calculation will be made. The converted temperature will be displayed in an uneditable text field with an appropriate label. Specifications Structure your file name and class name on the following pattern: The first three letters of your...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT