View the step-by-step solution to:

# Can someone please help me get this program running. What am I missing?

Can someone please help me get this program running. What am I missing?

import java.util.Scanner;

public class TestUSCrime {

private static long timeStart;

private static long timeEnd;

private static Scanner input;

//Menu

private static void showMenu() {

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

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

"1. What were the percentages in population growth for each consecutive year from 1994 to 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 year was the Larceny rate the highest?");

System.out.println("7. What year was the Larceny rate the lowest?");

System.out.println("8. What year was the Violent Crime rate the highest?");

System.out.println("9. What year was the Violent Crime rate the lowest?");

System.out.println("10. What year was the Rape rate the highest?");

System.out.println("11. What year was the Rape rate the lowest?");

System.out.println("12. What year was the Aggravated Assault rate the highest?");

System.out.println("13. What year was the Aggravated Assault rate the lowest?");

System.out.println("14. What year was the Property Crime rate the highest?");

System.out.println("15. What year was the Property Crime rate the lowest?");

System.out.println("16. What year was the Motor Vehicle Crime rate the highest?");

System.out.println("17. What year was the Motor Vehicle Crime rate the lowest?");

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

System.out.print("n Enter your selection: ");

}

public static void main(String[] args) {

String fileName = "";

String choice = "";

input = new Scanner(System.in);

timeStart = System.currentTimeMillis();

if (args.length == 0) {

System.out.println("No argument provided.");

return;

}

fileName = args[0];

Crime objCrime = new Crime(filename);

//Loop - continue running until user quits

while (!choice.equalsIgnoreCase("Q")) {

showMenu();

choice = input.nextLine();

if (!choice.equalsIgnoreCase("Q")) {

//Population growth

if (choice.equals("1"))

objCrime.printPopulationGrowth();

//Highest Murder rate

else if (choice.equals("2"))

System.out.println("nThe Murder rate was highest in " + objCrime.HighestMurderRateYear() + "n";

//Lowest Murder rate

else if (choice.equals("3"))

System.out.println("nThe Murder rate was lowest in " + objCrime.LowestMurderRateYear() + "n";

//Highest Robbery rate

else if (choice.equals("4"))

System.out.println("nThe Robbery rate was highest in " + objCrime.HighestRobberyRateYear() + "n";

//Lowest Robbery rate

else if (choice.equals("5"))

System.out.println("nThe Robbery rate was lowest in " + objCrime.LowestRobberyRateYear() + "n";

//Highest Larceny rate

else if (choice.equals("6"))

System.out.println("nThe Larceny rate was highest in " + objCrime.HighestLarcenyRateYear() + "n";

//Lowest Larceny rate

else if (choice.equals("7"))

System.out.println("nThe Larceny rate was lowest in " + objCrime.LowestLarcenyRateYear() + "n";

//Highest Violent Crime rate

else if (choice.equals("8"))

System.out.println("nThe Violent Crime rate was highest in " + objCrime.HighestViolentCrimeRateYear() + "n";

//Lowest Violent Crime rate

else if (choice.equals("9"))

System.out.println("nThe Violent Crime rate was lowest in " + objCrime.LowestViolentCrimeRateYear() + "n";

//Highest Rape rate

else if (choice.equals("10"))

System.out.println("nThe Rape rate was highest in " + objCrime.HighestRapeRateYear() + "n";

//Lowest Rape rate

else if (choice.equals("11"))

System.out.println("nThe Rape rate was lowest in " + objCrime.LowestRapeRateYear() + "n";

//Highest Aggravated Assault rate

else if (choice.equals("12"))

System.out.println("nThe Aggravated Assault rate was highest in " + objCrime.HighestAggravatedAssaultRateYear() + "n";

//Lowest Aggravated Assault rate

else if (choice.equals("13"))

System.out.println("nThe Aggravated Assault rate was lowest in " + objCrime.LowestAggravatedAssaultRateYear() + "n";

//Highest Property Crime rate

else if (choice.equals("14"))

System.out.println("nThe Property Crime rate was highest in " + objCrime.HighestPropertyCrimeRateYear() + "n";

//Lowest Property Crime rate

else if (choice.equals("15"))

System.out.println("nThe Property Crime rate was lowest in " + objCrime.LowestPropertyCrimeRateYear() + "n";

//Highest Motor Vehicle Crime rate

else if (choice.equals("16"))

System.out.println("nThe Motor Vehicle Crime rate was highest in " + objCrime.HighestMotorVehicleCrimeRateYear() + "n";

//Lowest Motor Vehicle Crime rate

else if (choice.equals("17"))

System.out.println("nThe Motor Vehicle Crime rate was lowest in " + objCrime.LowestMotorVehicleCrimeRateYear() + "n";

else System.out.println("nInvalid Choice. Please choose a valid option.n");

}

else {

timeEnd = System.currentTimeMillis();

System.out.println("nThank you for using the US Crimes Statistical Application.");

System.out.println("nElapsed time in seconds was: " + getElapsedTime());

}

}

}

private static long getElapsedTime() {

return (timeEnd - timeStart) / 1000;

}

}

#### Top Answer

Your code contains only a few basic syntax... View the full answer

2 comments
• I made the changes, but now I'm getting a few more errors. Could you help with this and help make the other set of code that goes with it?
• jjoseph818
• May 06, 2018 at 8:34pm
• import java.util.Scanner; public class TestUSCrime { private static long timeStart; private static long timeEnd; private static Scanner input; //Menu private static void showMenu() { System.out.println("***** Welcome to the US Crime Statistical Application *****n"); System.out.println("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 to 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 year was the Larceny rate the highest?"); System.out.println("7. What year was the Larceny rate the lowest?"); System.out.println("8. What year was the Violent Crime rate the highest?"); System.out.println("9. What year was the Violent Crime rate the lowest?"); System.out.println("10. What year was the Rape rate the highest?"); System.out.println("11. What year was the Rape rate the lowest?"); System.out.println("12. What year was the Aggravated Assault rate the highest?"); System.out.println("13. What year was the Aggravated Assault rate the lowest?"); System.out.println("14. What year was the Property Crime rate the highest?"); System.out.println("15. What year was the Property Crime rate the lowest?"); System.out.println("16. What year was the Motor Vehicle Crime rate the highest?"); System.out.println("17. What year was the Motor Vehicle Crime rate the lowest?"); System.out.println("Q. Quit the program."); System.out.print("n Enter your selection: "); }
• jjoseph818
• May 06, 2018 at 8:34pm

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents
• ### -

Question & Answers

Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

Ask a Question
Ask a homework question - tutors are online