I'm new to java and writing a program that accepts user input for a password and it has to meet the following requirements:
1. At least 6 characters long.
2. Leading character can't be a digit.
3. Password must have at least 1 digit.
4. Password must have at least 1 upper case letter.
The main method will keep asking the user for a password (using a while loop) until it gets one that's okay.
The other method has the signature:
public static boolean checkPassword (String word)
How do I write the while loop and checkPassword? PLEASE HELP!
1. At least 6 characters long.
2. Leading character can't be a digit.
3. Password must have at least 1 digit.
4. Password must have at least 1 upper case letter.
The main method will keep asking the user for a password (using a while loop) until it gets one that's okay.
The other method has the signature:
public static boolean checkPassword (String word)
How do I write the while loop and checkPassword? PLEASE HELP!
Code:
import java.util.Scanner;
public class Password
{
public static void main (String[] args)
{
Scanner input;
input = new java.util.Scanner(System.in);
String pword = "";
boolean checkPassword;
System.out.print("Please enter a new password:");
pword = input.nextLine();
while (checkPassword == false);
{
System.out.println("Your password does not meet the requirements!");
}}
public static boolean checkPassword (String pword)
{
boolean bHasNUmeric = false;
boolean bHasUpper = false;
Comment