Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I just stucked here and please help me complete this and make some explanation package Lab1; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class PasscodeCracker

I just stucked here and please help me complete this and make some explanation package Lab1; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class PasscodeCracker { public static void main(String[] args) { try { // Open the file that contains the secret // TODO: Create a file called passcode containing a string Scanner pwdscan = new Scanner(new File("passcode.txt")); // TODO: Read the secret in from the file System.out.println("test.txt file:"); while(pwdscan.hasNextLine()) { System.out.println(pwdscan.nextLine()); } pwdscan.close(); // TODO: Decide how many tries the user can have and store it in an integer int x = 5; // TODO: create a while loop for your passcode cracker game while( x > 0 ); // TODO: Print the password as stars (e.g. if the password is "hello", print *****) // TODO: within the while loop ask the user to guess a character // TODO: If guessed correctly, we reveal part of the hidden password and print the passcode // TODO: If all characters are revealed, break // TODO: If character is not guessed correctly, print try again // TODO: For both cases reduce the number of tries and if the tries == 0, break // TODO: If the password is revealed, print "Congratulations, the password is ..." // TODO: If the password is not revealed, print "Sorry you failed :(" } catch (FileNotFoundException e) { System.out.println("File Not Found"); e.printStackTrace(); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions

Question

What is the relationship between diversity, inclusion, and equity?

Answered: 1 week ago