Im assuming DFA here refers to Deterministic Finite Automaton
i think this method should suffice your question
public String validatePassword(String password)
{
if(password.length<8)
{
return "password length less than 8 characters";
}
else if(password.charAt(0)!='@')
{
return "password must start with a @ character";
}
else if(!Character.isUpperCase(password.charAt(password.length)))
{
return "Password must end with an Uppercase letter";
}
else
{
int noOfDigits=0;
for(int i=0;i<password.length;i++)>
{
if(Character.isDigit(password.charAt(i)))
{
noOfDigits++;
}
}
if(noOfDigits>=2)
{
return "password is valid";
}
else
{
return "password must contain at least 2 digits";
}
}
}
Create a String object rather than a 2d char array in java / C#
accept the password and call the above method passing the password to it.