I have to write a loop that steps through each character of a string checking for a digit and a hyphen in a social security number. how can i write the loop if I have an if statement already made for the other items i have to check for already such as the following code I have. Thanks
if (ssn.length() != 11)
{
throw new SocSecException(" wrong number of characters.");
}
else if (ssn.charAt(3) != '-' || ssn.charAt(6) != '-')
{
throw new SocSecException(" dashes at wrong positions.");
}
else
{
return true;
}


Reply With Quote
