Question: Program with a method calledpasswordCheckto return if the string is a valid password. The method should have the signature shown in the starter code. The
Program with a method calledpasswordCheckto return if the string is a valid password. The method should have the signature shown in the starter code.
The password must be at least 8 characters long and mayonlyconsist of letters and digits. To pass the autograder, you will need to print the boolean return value from thepasswordCheckmethod.
Hint: Consider creating a String that contains all the letters in the alphabet and a String that contains all digits. If the password has a character that isn't in one of those Strings, then it's an illegitimate password!
public class Password { public static void main(String[] args) { // Prompt the user to enter their password and pass their string // to the passwordCheck method to determine if it is valid. } public static boolean passwordCheck(String password) { //method so that it checks to see that the password // is at least 8 characters long and only contains letters // and numbers. } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
