I'm trying to create an email account and one of the requirements is to make a "reset password" function. So far, this is what I have.
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner user_input = new Scanner(System.in);
int option;
System.out.print("Choose one of the following options (by typing the corresponding number): ");
System.out.print("\n 1: Create a new email address: ");
System.out.print("\n 2: Reset Password: ");
Scanner keyboard = new Scanner(System.in);
option = keyboard.nextInt();
if (option == 1)
{
System.out.print("\n Please enter your first initial and then your last name separated by a single space: ");
String input = user_input.nextLine();
String name = input.toLowerCase();
String name2 = name.replaceAll("\\s","");
String endOfAddress = "@marquette.edu";
String emailAddress = "Your email address is: " +name2+""+endOfAddress+"";
System.out.println(emailAddress);
}
if (option == 2)
{
System.out.print("\n Please enter your new password");
String password = user_input.nextLine();
if (password.length() < 8 || password.length() > 24);
System.out.println("The password must be at least 8 characters, but no more than 24");
if (password.contains(" "))
System.out.println("The password cannot contain any spaces");
if (password.equals(password.toLowerCase())== true)
System.out.println("Password must contain at least one uppercase letter");
else
System.out.println("Please re-enter your new password");
My concern is with checking if the password is at least 8 characters or less than 24 characters. Even if the password has the right amount of characters, it still says that I have to adjust the password length. Also, if I fulfill the requirements of my password (at least 8 characters but no more than 24, no spaces, and at least one uppercase), it responds with an error code. Any suggestions?
Aucun commentaire:
Enregistrer un commentaire