Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(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 digits

Explanation / 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")); } }