Reformat a Phone Number
Write a function called reformatPhoneNumber
.
It should take a String
containing a phone number in the format 111-222-3333
and return it reformatted as
(111) 222-3333
.
You will want to explore the various
String
methods
to help you with this task.
In particular, you may find split
and substring
helpful.
There are solutions that use split
, others that use substring
, and probably others that use neither!