Help with java . can someone make it compile with pictures please!
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 here : https://owd.tcnj.edu/~papamicd/name_data.txt
Classes Required
Methods:
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
Assessment
Evaluation of project success will be determined by the following criteria:
PROGRAM:
/*
Name:
Class Name:
Assignment:
Project Name: Name Surfer
Project Description: This is a simple project that
uses the data provided by the Social Security Administration and
analyses baby name popularities
*/
package project;
import java.util.*;
import java.lang.*;
import java.io.*;
import project.StdDraw;
import java.awt.Font;
class NameRecord{
int START = 1900; // defines the start year
int DECADES = 11; // defines the number of decades in
data
int[] ranks = new int[11]; // stores the rank of that
name for the years 1900,1910,..,2000
String name; // stores the name
//Constructor to initialise the NameRecord object
with the name nad its rank over the decades using individual lines
from the file
NameRecord(String line){
String[] words = line.split(" ");//
used to store all the words of a line , line is of the format - [
NAME RANK1 RANK2 ... RANK11 ]
name = words[0];
for(int i=1;i<12;i++){
ranks[i-1] =
Integer.parseInt(words[i]);
}
}
//Simple function which returns the name of the
NameRecord object
String getName(){
return name;
}
//Simple function to get the rank of a particular name
in a decade(0-1900,1-1910,..,10-2000)
int getRank(int decade){
return ranks[decade];
}
//Simple function to return the year when the name
was most popular
int bestYear(){
int bestFoundRank = 1111; //stores
the best rank found so far while traversing the ranks array
int bestYr = START; // stores the
best year found so far while traversing the ranks array
for(int i=0;i<11;i++){
if(ranks[i]<bestFoundRank && ranks[i]>0){
bestFoundRank = ranks[i];
bestYr = START + i*10;
}
}
return bestYr;
}
}
class NameSurfer{
public static void main(String[] args){
Vector<String> lines = new
Vector<String>();// used to store all the lines in the
name_data.txt
BufferedReader reader; // used to
read all the lines from the name_data.txt file
try{
reader = new
BufferedReader(new
FileReader("/home/171070030/name_data.txt"));
String line =
reader.readLine(); //read the first line of the file
//until lines
are there read the lines and store them into the vector declared
above
while(line!=
null){
lines.add(line);
line = reader.readLine();
}
//close the
reader
reader.close();
int
numberOfLines = lines.size(); //stores the number of lines
Vector<NameRecord> records = new
Vector<NameRecord>();//using the lines we create individual
records and store them
for(int
i=0;i<numberOfLines;i++){
NameRecord newRecord = new
NameRecord(lines.elementAt(i));
records.add(newRecord);
}
boolean
validEntry = true; //used to terminate when 5 is selected as an
option
int selection;
//stores the option selected by the user
Scanner sc = new
Scanner(System.in); //used for user input
while(validEntry){
//Displaying the menu
System.out.println("1 - Find the best year for a
name");
System.out.println("2 - Find the best rank for a
name");
System.out.println("3 - Plot the popularity of a
name");
System.out.println("4 - Clear the plot");
System.out.println("5 - Quit");
System.out.println("Enter your
selection");
//obtain user's choice
selection = sc.nextInt();
String name; //used if options 1 or 2 or 3 is
selected
if(selection == 1){
//Find the best year for the
name
boolean nameFound =
false;
String temp =
sc.nextLine();
System.out.print("Enter the
name: ");
name = sc.nextLine();
for(int i=0;!nameFound
&& i<numberOfLines;i++){
if(records.elementAt(i).getName().equals(name)){
System.out.println(records.elementAt(i).bestYear());
nameFound = true;
}
}
if(!nameFound){
System.out.println("Name not found");
}
}else if(selection == 2){
//Find the best rank for a
name
boolean nameFound =
false;
String temp =
sc.nextLine();
System.out.print("Enter the
name: ");
name = sc.nextLine();
int indexOfBestRank;
for(int i=0;!nameFound
&& i<numberOfLines;i++){
if(records.elementAt(i).getName().equals(name)){
indexOfBestRank =
(records.elementAt(i).bestYear()-1900)/10;
System.out.println(records.elementAt(i).ranks[indexOfBestRank]);
nameFound = true;
}
}
if(!nameFound){
System.out.println("Name not found");
}
}else if(selection == 3){
//Plot the popularity of the name
boolean nameFound =
false;
System.out.print("Enter the
name: ");
String tmp =
sc.nextLine();
name =
sc.nextLine();
//Setting up the canvas
StdDraw.setCanvasSize(800,800);
StdDraw.setXscale(0,120);
StdDraw.setYscale(0,1000);
StdDraw.setPenColor(StdDraw.BLACK);
for(int i=0;!nameFound
&& i<numberOfLines;i++){
if(records.elementAt(i).getName().equals(name)){
//Displaying the X and Y axis
StdDraw.line(2,10,119,10);
StdDraw.line(3,3,3,999);
StdDraw.setPenColor(StdDraw.RED);
nameFound = true;
int[] Ranks = records.elementAt(i).ranks;
//If any rank is 0 then replace it by 1111
for(int j=0;j<11;j++){
if(Ranks[j]==0)
Ranks[j] =
1111;
}
//Drawing the first line by using the first two
ranks i.e. of 1900 and 1910
StdDraw.line(10,7500*(1.0/Ranks[0]),20,7500*(1.0/Ranks[1]));
//Drawing the lines further using consecutive
pair of points
for(int j=1;j<=9;j++){
StdDraw.line((j+1)*10,7500*(1.0/Ranks[j]),(j+2)*10,7500*(1.0/Ranks[j+1]));
}
//Displaying the points along with the
co-ordinates
StdDraw.setPenColor(StdDraw.BLUE);
StdDraw.setPenRadius(0.008);
Font font = new Font("Arial", Font.ITALIC,
10);
StdDraw.setFont(font);
for(int j=0;j<11;j++){
StdDraw.point((j+1)*10,7500*(1.0/Ranks[j]));
StdDraw.textLeft((j+1)*10,7500*(1.0/Ranks[j]),"("+String.valueOf(1900+(j)*10)+","+String.valueOf(Ranks[j])+")");
}
}
}
if(!nameFound){
System.out.println("Name not found");
}
}else if(selection == 4){
//Clear the plot
System.out.println("clearing the plot...");
StdDraw.clear();
}else{
//Exits the
program provided the plot is exited
System.out.println("Exiting
the program...");
validEntry = false;
}
}
}catch(IOException e){
e.printStackTrace();
}
}
}
SCREENSHOTS:






OUTPUT:



In the above project ,I have created a project directory in which I have two files namely NameSurfer.java and the other one is StdDraw.java. Both of these java files have as their first lines - 'package project' so that I could use StdDraw in NameSurfer class.
Help with java . can someone make it compile with pictures please! For this project, you...
Help with java . 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,...
Java Homework Help. Can someone please fix my code and have my
program compile correctly? Thanks for the help.
Specifications:
The class should have an int field named monthNumber that holds
the number of the month. For example, January would be 1, February
would be 2, and so forth. In addition, provide the following
methods.
A no- arg constructor that sets the monthNumber field to 1.
A constructor that accepts the number of the month as an
argument. It should...
Can someone compile this and name the it A4MA5331550.java and compile to make .class file. Will need to name . class file A4MA5331550 also when done put both files in a zipped folder named A4MA5331550 and email the folder to ensaye@gmail.com here is the program: import java.util.Scanner; /** * 09/17/2017 * Dakota Mammedaty * MA5331550 * Bubble sorted */ public class MA5331550 { public static void main(String[] args) throws IOException { Sort st =new Sort(); st.getData(); System.out.println("=================Sorting Algorithms================="); System.out.println("1. Bubble...
Copy the following java codes and compile //// HighArray.java //// HighArrayApp.java Study carefully the design and implementation HighArray class and note the attributes and its methods. Create findAll method which uses linear search algorithm to return all number of occurrences of specified element. /** * find an element from array and returns all number of occurrences of the specified element, returns 0 if the element does not exit. * * @param foundElement Element to be found */ int findAll(int...
JAVA project PLEASE complete/ create project with comments in
the programming explaining everything
Text file
Year of storm/ Name of storm/ mmdd storm started/ mmdd storm
ended/ magnitude of storm/ //made up data
2004/Ali/1212/1219/1
2003/Bob/1123/1222/3
1980/Sarah/0123/0312/0
1956/Michael/1211/1223/4
1988/Ryan/0926/1019/
1976/Tim/0318/1010/0
2006/Ronald/0919/1012/2
1996/Mona/0707/0723/1
2000/Kim/0101/0201/1
2001/Jim/1101/1201/3
Text file
Class storm{
private String nameStorm;
private int yearStorm;
private int startStorm;
private int endStorm;
private int magStorm;
public storm(String name, int year, int start, int end, int
mag){
nameStorm = name;
yearStorm = year;
startStorm...
(JAVA) Use the Pet.java program from the original problem (down below) Compile it. Create a text file named pets10.txt with 10 pets (or use the one below). Store this file in the same folder as your “class” file(s). The format is the same format used in the original homework problem. Each line in the file should contain a pet name (String), a comma, a pet’s age (int) in years, another comma, and a pet’s weight (double) in pounds. Perform the...
I've done all questions except question 6. how do I do
this? please help.
code needs to be java
1. You need to be able to open and read the text files that have been provided for the project. Write a Java program that reads the driver.txt file and displays each data value for each line from the file to the screen in the following format: Licence Number: Licence Class: First Name: Last Name: Address: Suburb: Postcode: Demerit Points: Licence...
Please, please help with C program.
This is a longer program, so take your time. But please make
sure it meets all the requirements and runs.
Here is the assignment:
I appreciate any help given.
Cannot use goto or system(3) function unless directed to.
In this exercise you are to create a database of dogs in a file, using open, close(), read, write(), and Iseek(). Do NOT use the standard library fopen() ... calls! Be sure to follow the directions!...
Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h (Given. Just use it, don't change it!) Student.cpp (Partially filled, need to complete) 1. Assignment description In this assignment, you will write a simple class roster management system for ASU CSE100. Step #1: First, you will need to finish the design of class Student. See the following UML diagram for Student class, the relevant header file (class declaration) is given to you as Student.h,...
Assignment on Java programing 1. Write programs for the following exercises in Java. Each file should have short description of the implemented class and for files with main method the problem it is solving. Make sure your files have appropriate names. Programs should write output to the Console. b) BST: Implement Binary Search Tree ADT with insert(int key), delete(int key), Node find(int key), and in-order traverse() where it prints the value of the key. Your operations should use recursion. The...