Chapter 5: Assignments
Monday, February 27th, 2006Page 413, Problem #6
Page 413, Problem #7
Page 413, Problem #6
Page 413, Problem #7
I’ve created an area for you to download the in class examples.
Page 412, Problem #1
public boolean isValidPhone(String sAreaCode, String sPrefix, String sSuffix)
{
return this.isValidPhonePart(sAreaCode,3) && this.isValidPhonePart(sSuffix,4);
}
public boolean isValidPhonePart(String sValue, int iLength)
{
for(int iCounter = 0; iCounter < sValue.length(); iCounter++)
{
switch(sValue.charAt(iCounter))
{
case ‘0′:
case ‘1′:
case ‘2′:
break;
default:
return false;
}
}
return (sValue.length() == iLength);
}
Bad Behavior has blocked 25 access attempts in the last 7 days.