Help on a HW assignment if password is valid or invalid?
i don't know why i can't understand how to write some code. maybe it's because it's been a yr since i took my last java class, but i am having trouble in coding this HW.
this is our given code :
Code Java:
public class Lab5 {
public static void main(String[] args) {
// Prompt the user to enter a password
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("Enter a string for password: ");
String s = input.nextLine();
if (isValidPassword(s)) {
System.out.println("Valid password");
}
else {
System.out.println("Invalid password");
}
}
/** Check if a string is a valid password */
public static boolean isValidPassword(String s) {
}
}
we do not have to change anything in the main method, we are suppose to only write code in the isValidPassword method. the requirements are:
• A password must starts with a letter.
• A password consists of only letters and digits. - this i think i need a for loop
• A password must have at least six characters.
any help is appreciated, thanks
Re: Help on a HW assignment if password is valid or invalid?
Re: Help on a HW assignment if password is valid or invalid?