Home /
Expert Answers /
Computer Science /
6-18-check-password-some-websites-impose-certain-rules-for-passwords-write-a-method-that-checks-pa313
(Solved): 6-18) (Check password) Some websites impose certain rules for passwords. Write a method that checks ...
6-18) (Check password) Some websites impose certain rules for passwords. Write a method that checks whether a string is a valid password. Suppose the password rules are as follows: A password must have at least eight characters. A password consists of only letters and digits. A password must contain at least two digits. Write a program that prompts the user to enter a password and displays Valid Password if the rules are followed or Invalid Password otherwise. SAMPLE RUN #7: java CheckPassword Interactive Session Hide Invisibles Highlight: None Enter a password: Happy66Nights+ Valid Password Show Highlighted Only
Program in Java: import java.util.*; class Password{ //method to validate password public boolean checkPassword(String password) { //variable n to store length of the string int n = password.length();