(Java) write a method that checks whether a string is a valid password. Suppose
ID: 3750088 • Letter: #
Question
(Java) write a method that checks whether a string is a valid password. Suppose the password rules are as follows: • password must have at least eight charcters • password must contain only letters & digits • password must contain at least two digits (Java) write a method that checks whether a string is a valid password. Suppose the password rules are as follows: • password must have at least eight charcters • password must contain only letters & digits • password must contain at least two digits • password must have at least eight charcters • password must contain only letters & digits • password must contain at least two digitsExplanation / Answer
public class PasswordCheck { public static boolean isValidPassword(String s) { int digitCount = 0; char ch; for(int i = 0; i = 8 && digitCount >= 2; } public static void main(String[] args) { System.out.println(isValidPassword("hello")); System.out.println(isValidPassword("he34llo0o")); } }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.