When people enter their telephone numbers into a form they use many different formats. Some examples are:
(444) 999-1234 4449991234 444.999.1234In the
PhoneNumbers
class below, complete the
cleanNumber
method. It takes a string and extracts the numeric
digits from the string. If there are exactly 10 numeric digits, the number is
reformatted: (###) ###-####
and returned. If there are any other
number of digits, the string "Error"
is returned.
Hint: Use the Character.isDigit
method to check whether a
character is a digit.