Question
This looks good. Now you want to start timing it. Import java.util.concurrent.TimeUnit; then create variables long startTime = 0; long endTime = 0; long[] duration
This looks good. Now you want to start timing it. Import java.util.concurrent.TimeUnit; then create variables long startTime = 0; long endTime = 0; long[] duration = new long[iter]; long maxTime = 0; long placeholder = 0; int max_index = 0; // finish where I put comments Scanner scan = new Scanner(System.in); String passwordGuess = ""; System.out.print("Enter your password: "); String password = scan.nextLine(); String guess = ""; for (int n = 5; n <= 11; n++) { // another for loop (lets to 10 times at first but may need to get up to like 100) guess = generateRandomString(n); //stat time if (guess.length() == password.length()) { break; } //end time // save end time - start time into index in duration array // end loop placeholder = getMaxValue(duration); // I created the getMaxValue for you // if placeholder is greater the maxTime // then max_index should be set equal to i // and maxTime should be set equal to placeholder } int c = 0; for(int i = 0;i
* I have been tasked to c_reate a program that guesses a password and implements timing when guessing the password. This is my code so far without the timing implemented. I am supposed to finish the code off by creating the following variables as per the comments within the code. All help is greatly appreciated!
Step 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