Question: You will implement a Implementation Overview of Files DO NOT edit ANY class besides StopAndFrisk java For all of these, look at the comments above

You will implement a Implementation
Overview of Files DO NOT edit ANY class besides StopAndFrisk java
For all of these, look at the comments above the methods for more information.
readFile()
Remember that you must call readFile every time you test a new CSV file, before calling any other meth
Use the Stdll library to read from a file:
To read one record do: string[] recordentries = stdin. readline()).split(","),
int year = recordEntries[0];
String description = recordEntries[2 String gender = recordEntries[52]
String race = recordEntries[66];
String location = recordEntries[7];
Boolean arrested = recordEntries[13].equals ("Y");
This method outputs the per year. To complete this method:
To complete this method: 1. Create two counters, one for the population frisked and the other for the population arrested. 2. Access the specifi year you are loking for in the database array. 3. Traversethe records in that year updating the counters. 1. Utilize gettris
=
Create counte black men wh women who 1. Utilize th 1. If 2. If th
Return the 2D resulting array
Note 1: We are loo male percentage. Note 2. The total
Note 2: The total percentages should not be above 100%
crimelncrease This method returns a double value representing the percentage of crime increase (if the number is positive) or crime decrease (if the number is negative between any 2 years. The parameters tor thingethod are the descripition of the record year 1,
'.'In the real world context - We always want a decrease in crime as the years progress. See if that's the case or not!
Notes:
Make su . year. Consider
Consider edge cases: yearl cannot be greater than or equal to year
mostCommonBorough This method outputs the NYC borough where the most amount of stops occurred in a given year. This method will analyze the five following boroughs in New York City: Brooklyn, Manhattan, Bronx, Queens, and Staten Island.
This is my code:
import java.util.ArrayList;
/**
* The StopAndFrisk class represents stop-and-frisk data, provided by
* the New York Police Department (NYPD), that is used to compare
* during when the policy was put in place and after the policy ended.
*
* @author Tanvi Yamarthy
* @author Vidushi Jindal
*/
public class StopAndFrisk {
/*
* The ArrayList keeps track of years that are loaded from CSV data file.
* Each SFYear corresponds to 1 year of SFRecords.
* Each SFRecord corresponds to one stop and frisk occurrence.
*/
private ArrayList database;
/*
* Constructor creates and initializes the @database array
*
* DO NOT update nor remove this constructor
*/
public StopAndFrisk (){
database = new ArrayList>();
}
/*
* Getter method for the database.
**** DO NOT REMOVE nor update this method ****
*/
public ArrayList getDatabase(){
return database;
}
/**
* This method reads the records information from an input csv file and populates
* the database.
*
* Each stop and frisk record is a line in the input csv file.
*
*1. Open file utilizing StdIn.setFile(csvFile)
*2. While the input still contains lines:
*- Read a record line (see assignment description on how to do this)
*- Create an object of type SFRecord containing the record information
*- If the record's year has already is present in the database:
*- Add the SFRecord to the year's records
*- If the record's year is not present in the database:
*- Create a new SFYear
*- Add the SFRecord to the new SFYear
*- Add the new SFYear to the database ArrayList
*
* @param csvFile
*/
public void readFile ( String csvFile ){
// DO NOT remove these two lines
StdIn.setFile(csvFile); // Opens the file
StdIn.readLine(); // Reads and discards the header line
// WRITE YOUR CODE HERE
String[] allLines = StdIn.readAllLines();
int len = allLines.length;
for (int i =0; i len; i++){
String[] recordEntries = allLines[i].split(",");
int year = Integer.parseInt(recordEntries[0]);
String description = recordEntries[2];
String gender = recordEntries[52];
String race = recordEntries[66];
String location = recordEntries[71];
Boolean arrested = recordEntries[13].equals("Y");
Boolean frisked = recordEntries[16].equals("Y");
SFRecord record = new SFRecord(description, arrested, frisked, gender, race, location);
boolean targetYearFound = false;
You will implement a Implementation Overview of

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!