Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Wrte a method thet loops forever until the user inpuis the cormect secret password or until the user fails to enter the cormect password 10
Wrte a method thet loops forever until the user inpuis the cormect secret password or until the user fails to enter the cormect password 10 times. The secret password the prograrm should look for is the String secret" public void secretPasswo rdO public void secretPasswo rdo) int count- while(true) int count 0; whi le(true) Use readl ine(String prompt) for user input if(count t10) if(count 10) ublic void secretPasswo public void secretPasswo System,out.p rinttn("You are locked o rdO System.out.p int count-e; while(true) rintin"You are locked o ut!"); ut!i return; int count 1; whileCtrue) if(count10) ifCtreadLineC"Pa snord?).equals("secret" sswond?").equatsC"secre System, out.p if Ccount 18) i fCreadLine("Pas System.out.p System.out.p intlnC"You ore locked t!) rintin("You are locked return System.out.P rintIn("Welcomeli return; rintin"Welcome!); return ifCreadLineC"Pas if(readline( Pas 0rd?").equat sC'secret")) siord?").equals("secret.): count++ ; count++: System,out.p System.out.p -intin("Welcome!) rintinC"Welcome! return return; count++ count++
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