|
-
Dec 9th, 2007, 07:07 PM
#1
Thread Starter
New Member
loop that checks for digits and hiphens
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;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|