Skip to content

Instantly share code, notes, and snippets.

@justinrolston
Created May 21, 2011 11:16
Show Gist options
  • Save justinrolston/984446 to your computer and use it in GitHub Desktop.
Save justinrolston/984446 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Unit8Project
{
public static void main (String[] args)
{
String apassword1;
String apassword2;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter a password: ");
apassword1 = keyboard.nextLine();
int apasswordlength;
apasswordlength = apassword1.length();
if (apasswordlength >= 6);
else System.out.print("The password you entered is invalid, please try again");
if( apassword1.matches(".*[a-zA-Z]+.*"));
else System.out.print("The password you entered is invalid, please try again");
if (apassword1.matches(".*[0-9].*"));
else System.out.print("The password you entered is invalid, please try again");
System.out.print("Re-enter your password: ");
apassword2 = keyboard.nextLine();
if (apassword1.equals(apassword2))
System.out.print("You have successfully created a password");
else
System.out.print("The password you entered does not match, please try again");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment