Question
public static void Lowest_Murder_Rate(ArrayList StoreList) { double min_Murderrate = Double.MAX_VALUE; int YYYY = 0; for (int i = 0; i fault.Murder_and_nonnegligent_manslaughter_rate) { min_Murderrate = fault.Murder_and_nonnegligent_manslaughter_rate;
public static void Lowest_Murder_Rate(ArrayList StoreList) { double min_Murderrate = Double.MAX_VALUE; int YYYY = 0; for (int i = 0; i fault.Murder_and_nonnegligent_manslaughter_rate) { min_Murderrate = fault.Murder_and_nonnegligent_manslaughter_rate; YYYY = (int) fault.YYYY; } } System.out.println("The murder rate was highest in the year : ---> " + YYYY); }
public static void Highest_Robbery_Rate(ArrayList StoreList) { double max_Robberyrrate = Double.MIN_VALUE; int yyyy = 0; for (int i = 0; i " + yyyy); }
public static void Lowest_Robbery_Rate(ArrayList StoreList) { double min_Robberyrrate = Double.MAX_VALUE; int yyyy = 0; for (int i = 0; i Fault.Robbery_rate) { min_Robberyrrate = Fault.Robbery_rate; yyyy = (int) Fault.YYYY; } } System.out.println("Robbery_rate the LOWEST : ---> " + yyyy); }
public static US_Crime storeToCrimeObjin(String line) { String[] data = line.split(","); US_Crime fault = new US_Crime(data); return fault; } @SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) { long TimeStarted = System.currentTimeMillis(); System.out.println("********** Welcome to the US Crime Statistical Application **************************"); String InputFile = "Crime.csv";// give your in file try { ArrayList small = new ArrayList
small.add(storeToCrimeObjin(StrLine));
} // Close the input stream In.close(); Scanner Sc = new Scanner(System.in); char Ch = '\0'; while (Ch != 'Q') { Print_Menu.print_Menu(); Ch = Sc.next().charAt(0); switch (Ch) { case '1': Pop_Growth(small); break;
case '2': Highest_Murder_Rate(small); break;
case '3': Lowest_Murder_Rate(small); break;
case '4': Highest_Robbery_Rate(small); break;
case '5': Lowest_Robbery_Rate(small); break;
case '6': Motor_theft(small); break;
case '7': //Please defined clear explanation what to do break;
case '8': //Please defined clear explanation what to do break;
case 'Q': long TimeEnding = System.currentTimeMillis(); System.out.println("Thank you for trying the US Crimes Statistics Program."); System.out.println("Elapsed time in seconds was: " + (TimeEnding - TimeStarted) / 100); break;
default: System.out.println("Enter a valid menu selection"); } } } catch (Exception e) { } } }
//US_Crime.java: class US_Crime {
public double YYYY; public double Population; public double Violent_crime; public double Violent_crime_rate; public double Murder_and_nonnegligent_manslaughter; public double Murder_and_nonnegligent_manslaughter_rate; public double Rape; public double Rape_rate; public double Robbery; public double Robbery_rate; public double Aggravated_assault; public double Aggravated_assault_rate; public double Property_crime; public double Property_crime_rate; public double Burglary; public double Burglary_rate; public double Larceny_theft; public double Larceny_theft_rate; public double Motor_vehicle_theft; public double Motor_vehicle_theft_rate;
public US_Crime(String[] data) { YYYY = Double.parseDouble(data[0]); Population = Double.parseDouble(data[1]); Violent_crime = Double.parseDouble(data[2]); Violent_crime_rate = Double.parseDouble(data[3]); Murder_and_nonnegligent_manslaughter = Double.parseDouble(data[4]); Murder_and_nonnegligent_manslaughter_rate = Double.parseDouble(data[5]); Rape = Double.parseDouble(data[6]); Rape_rate = Double.parseDouble(data[7]); Robbery = Double.parseDouble(data[8]); Robbery_rate = Double.parseDouble(data[9]); Aggravated_assault = Double.parseDouble(data[10]); Aggravated_assault_rate = Double.parseDouble(data[11]); Property_crime = Double.parseDouble(data[12]); Property_crime_rate = Double.parseDouble(data[13]); Burglary = Double.parseDouble(data[14]); Burglary_rate = Double.parseDouble(data[15]); Larceny_theft = Double.parseDouble(data[16]); Larceny_theft_rate = Double.parseDouble(data[17]); Motor_vehicle_theft = Double.parseDouble(data[18]); Motor_vehicle_theft_rate = Double.parseDouble(data[19]); } }
//PrintMenu.java: class Print_Menu { public static void Print_Menu(){ System.out.println("Enter the number of the question you want answered. Enter Q to quit the program :"); 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 was 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("6. What was the total percentage change in Motor Vehicle Theft between 1998 and 2012?"); System.out.println("7. What was [enter your first unique statistic here]?"); System.out.println("8. What was [enter your second unique statistic here]?"); System.out.println("Q. Quit the program"); } }
*******DATA TO USE******
Welcome to the US Crime Statisticel Application Enter the number of the question you want answered. Enter ' to quit the program 1. What were the percentages in population growth for each consecutive year from 1994-2013? 2. What year was the Murder rate the highast? 3. What year was the Murder rats the lowest? 4. What year was the Robbery rate the highest? S. What year was the Robbery rate the lowest Q Quit the program Design a lava application that will read a file containing data related to the US. Crime statistics from 1994-2013. The description of the file is at the end of this file. The application should provide statistical results on the data including Enter your selection: 2 The Murder rate was highest in 1994 Entar the number of the question you want answered. Entar r to quit the program a. Population growth in percentages from each consecutive year (eg 1994-1995 calculation is ((26290S276-2603270211/260327021)" 100-0.9512%, 1995-1996 would be ((265228572-262803276/262803276). 100-0922996) b. Years where the maximum and minimum Murder rates occurred. c. Years where the maximum and minimum Robbery rates accurred. What were the percantages in population growth for each consecutive year from 2. What year was the Murder rate the highest? 3. What year was the Murder rate the lowest? 4 What year was the Robbery rate the highest 5. What year was the Robbery rate the lowest Q Quit the program 1994-2013? The following are some design criteria and specific requirements that need to be addressed: Use command ine arguments to send in the name of the US Crime Data file. least two classes assienment USCrimeClass to store the fields. You can also have an Array of US Crime Objects.) getMaxMurderYearl) will return the Year where the Murder rate was highest. a. b. You should also use Java classes to their full extent to include multiple methods and at c. You are not allowed to modify the Crime.csv Statistic data file included in this d. Use arrays and Java classes to store the data. (Hint You can and should create a e. You should create separate methods for each of the required functionality. (c e f. A user-friendly and wel-organized menu should be used for users to select which data Enter your selection:5 The Robbery rate was lowest in 2013 Enter the number of the question you want answered. Enter ' to quit the program 1. What were the percentages in populstion growth for each consecutive year from 1994-2013 2 What year was the Murder rate the hichest? 3. What year was the Murder rate the lowest? 4. What year was the Robbery rate the highst? 5. What year was the Robbery rate the lowan? a. Ouit the program to return. A sample menu is shown in run example. You are free to enhance your design and you should add additional menu items and functionality e. The menu system should be displayed at the command prompt, and continue to redisplay after results are returned or until Q is selected. If a user enters an invalid menu tem, the system should redisplay the menu with a prompt asking them to enter a valid menu selection The application should keep track of the elapsed time (in seconds) between once the application starts and when the user quits the pragram. After the program is exited, the application should provide a prompt thanking the user for trying the US Crime Statistics program and providing the total time elapsed. Enter your h. Thank you for trying the US Crimes Statistics Program. i. Hint: When reading the Crimes file, read one line at a time (See ReadEmail. java) and then within the loop parse each line into the USCrimeClass fields and then store that USCrimedlass Object into an array, Note you can use String split to split the CSV line into a the fields for setting the USCrimeClass Object Here is sample run: import java.io.BufferedReader import java.io.DataInputStream import java.io.FileInputStream import java.io.InputStreamReader import java.util.ArrayList: import java.util.Scanner public class Testing_US_Crimet ublic static void Pop_Growth (ArrayList StoreList) System.out println("The percentages in population growth for each consecutive year from 1994- 2013" US_Crime Fault(Us_Crime) StoreList.get (i): US Crime Uscl - null; if (Fault.YYYY 1998 && Fault.YYYYStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started