Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 pwdscan.close(); // TODO: Decide how many tries the user can have and store it in an integer

// TODO: create a while loop for your passcode cracker game // 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(); }

}

}

code and explanation thanks

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

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

When would you use one approach, and when would you use another?

Answered: 1 week ago

Question

3. How would this philosophy fit in your organization?

Answered: 1 week ago