
7.18 Exercises,Problems,and Projects 461
EXERCISES,PROBLEMS, AND PROJECTS
We will assume that the interest rate is compounded annually. Write a
client class to test all the methods in your class.
71. Write a class encapsulating the concept of a telephone number,
assuming a telephone number has only a single attribute: a String rep-
resenting the telephone number. Include a constructor, the accessor
and mutator, and methods toString and equals. Also include methods
returning the area code (the first three digits/characters of the phone
number; if there are fewer than three characters in the phone number
or if the first three characters are not digits, ...