Do NOT use regular expressions Pattern or Matcher classes to

Do NOT use regular expressions, Pattern, or Matcher classes to solve this program; use appropriate String, StringBuffer, and/or Character methods.

Create a PswdChecker class definition in a single file (PswdChecker.jav) that has a single method:

public Boolean isValid(String Input)

This method will loop through the input String checking each character for the following rules:

-Each character can be a letter a-z or A-Z, a numeric digit, or any of the following characters: ‘@’ (the “at” sign), ‘ .’ (a “period”), ‘ _’ (underscore), ‘-‘ (dash), ‘~’ (tilde), ‘#’ (“pound” sign), ‘ !’ (exclamation point), ‘ &’ (ampersand), or ‘$’ (dollar)

-The input String must contain at least one non-letter character; that is, a character from the above list, not including a-z or A-Z.

-The input String cannot contain a space character (blank) or any character not in the first list above; it also cannot be an “empty” String.

-The input String must be no less than 8 characters in length

-The input String must contain at least one capitalized letter; that is, a character from the list, A-Z.

This method will return a true value if the password meets all of the above criteria, otherwise it will return a false value.

Additionally, this program will print on the system console appropriate output to log each verification, whether successful or unsuccessful. This log also will display the value of the password verified. This program will not do user input or other user output.

Solution

Here is the code for PasswordChecker.java:

import java.util.*;
class PasswordChecker
{
public boolean isValid(String password)
{
String symbol = \"@._-~#!&$\";
boolean accepted = false;
boolean hasLength = false;
int upperCaseCount = 0;
int lowerCaseCount = 0;
int digitCount = 0;
boolean hasSymbol = false;
if(password.length() >= 8) //Checks for length.
hasLength = true;
for(int i = 0; i < password.length(); i++) //For each character.
{
char c = password.charAt(i);
if(Character.isUpperCase(c))        //If uppercase, increment counter.
upperCaseCount++;
if(Character.isLowerCase(c)) //If lowercase, increment counter.
lowerCaseCount++;
if(Character.isDigit(c))            //If digit, increment counter.
digitCount++;
if(symbol.indexOf(c) != -1)       //If has symbol, mark flag.
hasSymbol = true;   
}
/*if(verbose == \'N\' || verbose == \'n\') //If no verbose is required.
if(hasLength && upperCaseCount > 1 && lowerCaseCount > 1 && digitCount > 1 && hasSymbol && hasLength)//If conforms.
return true;       //Returns true.
else
return false;
else*/           //If verbose is required. Print the relative message.
{
if(!hasLength)
System.out.println(\"Password length should be no less than 8.\");
if(upperCaseCount < 1)
System.out.println(\"Password should contain minimum 1 uppercase letter.\");
if(!hasSymbol)
System.out.println(\"Password should contain atleast one special characters from !, @, #, $, %, ^, &, *, (, ), ?\");
if(hasLength && upperCaseCount > 1 && lowerCaseCount > 1 && digitCount > 1 && hasSymbol && hasLength)
return true;
else
return false;
}
}

Do NOT use regular expressions, Pattern, or Matcher classes to solve this program; use appropriate String, StringBuffer, and/or Character methods. Create a Pswd
Do NOT use regular expressions, Pattern, or Matcher classes to solve this program; use appropriate String, StringBuffer, and/or Character methods. Create a Pswd

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site