Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Java Programming

14/10/2020 Client: happyw Deadline: 2 Day

Design a Java application that will read a file containing data related to the US. Crime statistics from 1994-2013.


Here are the codes I have so far:




public class USCrimeClass {




// Crime data fields for each data to retrieve


private int year;


private double populationGrowth;


private int maxMurderYear;


private int minMurderYear;


private int maxRobberyYear;


private int minRobberyYear;


/**


* Crime data constructor to set variables


*/


public USCrimeClass(int year, int populationGrowth, int maxMurderYear, int minMurderYear, int maxRobberyYear, int minRobberyYear){


this.year = year;


this.populationGrowth = populationGrowth;


this.maxMurderYear = maxMurderYear;


this.minMurderYear = minMurderYear;


this.maxRobberyYear = maxRobberyYear;


this.minRobberyYear = minRobberyYear;


}




// Constructor defaults


public USCrimeClass(int count){


this.year = 0;


this.populationGrowth = 0.0;


this.maxMurderYear = 0;


this.minMurderYear = 0;


this.maxRobberyYear = 0;


this.minRobberyYear = 0;


}




/**


* Getter methods for each field


* @return percentage growth and years for murder and robbery


*/


public int getYear() {return this.year; }


public double getPopulationGrowth() {return this.populationGrowth; }


public int getMaxMurderYear() {return this.maxMurderYear; }


public int getMinMurderYear() {return this.minMurderYear; }


public int getMaxRobberyYear() {return this.maxRobberyYear; }


public int getMinRobberyYear() {return this.minRobberyYear; }




// Setter method for each field


public void setYear(int year) {this.year = year;}


public void setPopulationGrowth(double populationGrowth) {this.populationGrowth = populationGrowth;}


public void setMaxMurderYear(int maxMurders) {this.maxMurderYear = maxMurders;}


public void setMinMurderYear(int minMurders) {this.minMurderYear = minMurders;}


public void setMaxRobberyYear(int maxRobbery) {this.maxRobberyYear = maxRobbery;}


public void setMinRobberyYear(int minRobbery) {this.minRobberyYear = minRobbery;}


}


















import java.io.File;


import java.util.Scanner;


import java.io.FileNotFoundException;




public class USCrimeFile {




public static USCrimeClass[] read(String filename){




// Array declaration


USCrimeClass[] stats = new USCrimeClass[20];


Scanner inputReader = null;


// Variable declaration


int count = 0;


String line;


// Access Crime.csv and create array


try {




File file=new File("Crime.csv");


inputReader = new Scanner(new File("Crime.csv"));


// Read first line


inputReader.nextLine();


while (inputReader.hasNext()) {




line = inputReader.nextLine();


String[] data = line.split(",");


stats[count] = new USCrimeClass(Integer.parseInt(data[0]));


stats[count].setPopulationGrowth(Integer.parseInt(data[1]));


stats[count].setMaxMurderYear(Integer.parseInt(data[4]));


stats[count].setMinMurderYear(Integer.parseInt(data[4]));


stats[count].setMaxRobberyYear(Integer.parseInt(data[8]));


stats[count].setMinRobberyYear(Integer.parseInt(data[8]));


count++;


}




return stats;


} catch (FileNotFoundException e) {


e.printStackTrace();


return stats;


}


finally {


inputReader.close();


}




}


// Method calculation for population growth rate


public void populationGrowth(USCrimeClass[] data){




double growthRate;


System.out.println("Population growth rate: ");


for (int i = 0; i < data.length - 1; i++){


growthRate = 100 * (float) (data[i+1].getPopulationGrowth() - data[i].getPopulationGrowth()) / data[i].getPopulationGrowth();


System.out.println("From " + data[i].getYear() + " to " + data[i + 1].getYear() + " the population growth was "+ String.format("%.4f", growthRate) + "%");


}


}




// Method to find year with highest murder rate


public String maxMurderYear(USCrimeClass[] data) {


int iSize = data.length;


double currentMurderRate = 0.00;


double mMurderRate;


int murderHighYear = 0;


String stReturnValue;


// Access array


try {


for (int i = 0; i < iSize; i++) {




// Get murder rate


mMurderRate = data[i].getMaxMurderYear();


if (mMurderRate < currentMurderRate) {


murderHighYear = data[i].getYear();


}


currentMurderRate = mMurderRate;


}


stReturnValue = "The murder rate was highest in " + murderHighYear + ".";


return stReturnValue;


}


catch(Exception e){


System.out.println("Exception" + e.getMessage());


return null;


}


}




// Method to find lowest murder year


public String minMurderYear(USCrimeClass[] data) {


int iSize = data.length;


double currentMurderRate = 0.00;


double mMurderRate;


int murderLowYear = 0;


String stReturnValue;


try {


// Access array


for (int i = 0; i < iSize; i++) {




// Get the murder rate


mMurderRate = data[i].getMinMurderYear();


if (mMurderRate > currentMurderRate) {


murderLowYear = data[i].getYear();


}


currentMurderRate = mMurderRate;


}


stReturnValue = "The murder rate was lowest in " + murderLowYear + ".";


return stReturnValue;


} catch (Exception e) {


System.out.println("Exception" + e.getMessage());


return null;


}


}


// Get the year with highest robberies


public String maxRobberyYear(USCrimeClass[] data) {


int iSize = data.length;


double currentRobberyRate = 0.00;


double dRobberyRate;


int robberyHighYear = 0;


String stReturnValue;


// Access array


try {


for (int i = 0; i < iSize; i++) {




// Get the robbery rate


dRobberyRate = data[i].getMaxRobberyYear();


if (dRobberyRate < currentRobberyRate) {


robberyHighYear = data[i].getYear();


}


currentRobberyRate = dRobberyRate;


}


stReturnValue = "The robbery rate was highest in " + robberyHighYear + ".";


return stReturnValue;


} catch (Exception e) {


System.out.println("Exception" + e.getMessage());


return null;


}


}




// Method to find lowest robbery year


public String minRobberyYear(USCrimeClass[] data) {


int iSize = data.length;


double currentRobberyRate = 0.00;


double dRobberyRate;


int robberyLowYear = 0;


String stReturnValue;


// Access array


try {


for (int i = 0; i < iSize; i++) {




// Get robbery rate


dRobberyRate = data[i].getMinRobberyYear();


if (dRobberyRate > currentRobberyRate) {


robberyLowYear = data[i].getYear();


}


currentRobberyRate = dRobberyRate;


}


stReturnValue = "The robbery rate was lowest in " + robberyLowYear + ".";


return stReturnValue;


} catch (Exception e) {


System.out.println("Exception" + e.getMessage());


return null;


}


}


}


















import java.util.Scanner;




public class TestUSCrime {




static Scanner input = new Scanner(System.in);


public static void main(String[] args) {




/**


* Reference USCrimeFile


*/


USCrimeFile oUSCrimeFile = new USCrimeFile();


USCrimeClass[] data = USCrimeFile.read("Crime.csv");


/**


* Declare variables


*/


long startTime = System.currentTimeMillis();


long endTime;


String userSelect;


while (true)


{


// Welcome prompt


System.out.println("\n******** Welcome to the US Crime Statistical Application********\n");


System.out.println("\n" + "Enter the number of the question you want answered. Enter 'Q' to quit the program:\n");


System.out.println("1. What were the percentages in population growth for each consecutive year from 1994-2013?");


System.out.println("2. What year was the murder rate the highest?");


System.out.println("3. What year wat the murder rate the lowest?");


System.out.println("4. What year was the robbery rate the highest?");


System.out.println("5. What year was the robbery rate the lowest?");


System.out.println("Q. Quit the program");


System.out.println("\nEnter your selection: ");


userSelect = input.nextLine();


System.out.println();


switch (userSelect){




case "1":


oUSCrimeFile.populationGrowth(data);


break;


case "2":


System.out.println("The murder rate was highest in " + oUSCrimeFile.maxMurderYear(data));


break;


case "3":


System.out.println("The murder rate was lowest in " + oUSCrimeFile.minMurderYear(data));


break;


case "4":


System.out.println("The robbery rate was highest in: " + oUSCrimeFile.maxRobberyYear(data));


break;


case "5":


System.out.println("The robbery rate was highest in: " + oUSCrimeFile.minRobberyYear(data));


break;


case "Q":


System.out.println("\nThank you for trying the US Crime Statistics Program");


endTime = System.currentTimeMillis();


System.out.println("\nElapsed time in seconds was: " + (endTime - startTime) / 1000 + "seconds.");


System.exit(0);


}


}


}


}

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Quality Homework Helper
Online Assignment Help
Buy Coursework Help
Pro Writer
Top Writing Guru
Top Grade Essay
Writer Writer Name Offer Chat
Quality Homework Helper

ONLINE

Quality Homework Helper

Hi dear, I am ready to do your homework in a reasonable price.

$47 Chat With Writer
Online Assignment Help

ONLINE

Online Assignment Help

Hi dear, I am ready to do your homework in a reasonable price.

$40 Chat With Writer
Buy Coursework Help

ONLINE

Buy Coursework Help

Hi dear, I am ready to do your homework in a reasonable price.

$47 Chat With Writer
Pro Writer

ONLINE

Pro Writer

Hello, I can assist you in every kind of writing. I am a professional academic/research writer and an MBA in business and finance. Please connect in chat session to further discuss the details.

$40 Chat With Writer
Top Writing Guru

ONLINE

Top Writing Guru

I am an Academic writer with 10 years of experience. As an Academic writer, my aim is to generate unique content without Plagiarism as per the client’s requirements.

$45 Chat With Writer
Top Grade Essay

ONLINE

Top Grade Essay

Working on this platform from a couple of time with exposure of dynamic writing skills gathered with years experience on different other websites.

$47 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Writing Project 2—Posting Analysis; Writing Project 3—Annotated Resume - Difference between stream cipher and block cipher - Kobe bryant vs michael jordan comparison contrast essay - Chinese first language vce - In ipsg goal 5 is indicating that - Kla tencor annual report 2018 - What is five sixths of 30 - Homework 4 2 mystatlab module four problem set - Theme of la belle dame sans merci - Alexa Pearl: Bio, Age, Early Life, Instagram & ManyVids - Tastyworks day trade counter - Economics - Paper - In your audit of jose oliva company - Woodcock reading mastery tests fourth edition - What does a bindi represent - Analog filter design software - Elt oup student headway - Credit and borrowing general maths - Trading account format pdf - A focused differentiation strategy aims at securing competitive advantage - Crescent pure case study marketing research - Application Security - How to prepare a bank reconciliation and record adjustments - University of bath campus map - A puzzle with many pieces development of the periodic table - HA560 Unit 7 Discussion - Testout network pro certification practice exam answers - Creating a company culture for security design document - Joint assignment - Contextual meaning of the underlined phrases - Case Study 5 - One Page Argumentative Essay - Wire gauze science definition - Determination of melting point practical - Staples color copy price - The beatles and the monkees nyt crossword - Answer a questions - Fair verona romeo juliet - A saturated liquid vapor mixture of water - Dunkin donuts balance sheet - Greenfield Investments - Luther felt that music distracted from worship and should not be in church services. - The task of stitching together a strategy - Gleim cia test bank - Honeywell estate agents clitheroe - Operations Management - Alpaca berserk male syndrome - Biology of human sexuality valencia - Compound words pdf worksheets - Https ci3 googleusercontent com proxy - 425 channel road merbein - COM510 Week 10 - What adjustment is made for underapplied overhead - Is collateral beauty on redbox - Management‌ ‌traits,‌ ‌theories‌ ‌and‌ ‌leadership‌ ‌ ‌ - Australian society for biochemistry and molecular biology - Name and explain two types of prewriting weegy - Net Neutrality Discussion Board - Samsung fridge freezer da68 - Charlton college of business - Assessment for crisis intervention a triage assessment model - The Evolution and Versatility of Embroidered Patches - Current issue artical - Microsoft excel qm add in - Mickleover primary learning platform - Managerial and legal ethics - En 1363 1 fire resistance tests - University of the cumberlands blackboard - The adjusted trial balance for rowdy profits corporation - Flash gordon villain crossword clue - Qualitative and quantitative research question - Cisrs scaffold supervisor course - Torre de manila demolition - Parts of a recipe - Beer pong knock over cup - I need 1000 words on Graphic and picture requirement as part of the Awards ceremony for 2019 - Different roles of a teacher - Netball league south africa - Country club management style - A specimen of aluminum having a rectangular - Reflection 6 - Excellence gateway esol entry 1 unit 5 - Benchmark gospel essentials - Guyland chapter 4 summary - Iso 9001 audit checklist for administration - Mass volume and density - Sigurd is the son of the god odin - The american dream still exists - Zen and the art of faking it sparknotes - Typological classification of languages - Microscopic hair analysis yields individual evidence - Converting watts to amps - Chemical suicide training for first responders - Case 3-2 - 5 axioms of communication gamble and gamble - Acquiring eligible employees - Milestones in language and literacy chart - The breadwinner novel study - Visit kiplinger com go troweprice