Your second task is to create a method called VerifyCredentials and return a Boo
ID: 3682622 • Letter: Y
Question
Explanation / Answer
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
boolean verify = verifyCredentials("mary", "503");
System.out.println("Verify is "+verify);
}
public static boolean verifyCredentials(String username, String pass)
{
boolean verified = false;
System.out.println("User " + username +" .Enter your password::");
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
if(input.equals(pass))
{
System.out.println("Correct password");
verified = true;
}else
{
System.out.println("Incorrect password Enter Again::");
input = sc.nextLine();
if(input.equals(pass))
{
System.out.println("Correct password");
verified = true;
}
else
{
System.out.println("Incorrect password Enter Again::");
input = sc.nextLine();
if(input.equals(pass))
{
System.out.println("Correct password");
verified = true;
}
else
System.out.println("Incorrect password. Locked account");
}
}
return verified;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.