Using a text editor, create a text file of several telephone numbers, using the two formats described previously. Write a program that reads this file, displays the data on the screen, and creates an array whose base type is TelephoneNumber. Allow the user to either add or delete one telephone number. Write the modified data on the text file, replacing its original contents. Then read and display the numbers in the modified file.

Write a class TelephoneNumber that will hold a telephone number. An object of this class will have the attributes
• areaCode—a three-digit integer
• exchangeCode—a three-digit integer
• number—a four-digit integer
and the methods
• TelephoneNumber(aString)—a constructor that creates and returns a new
instance of its class, given a string in the form xxx-xxx-xxxx or, if the area code is missing, xxx-xxxx. Throw an exception if the format is not valid. Hint: To simplify the constructor, you can replace each hyphen in the telephone number with a blank. To accept a telephone number containing hyphens, you could process the string one character at a time or learn how to use Scanner to read words separated by a character—such as a hyphen—other than whitespace.
• toString—returns a string in either of the two formats shown previously for the constructor.


See the code in InvalidTelephoneFormatException.java, TelephoneNumber.java, TelephoneProgram.java. Input is in numbers.txt

Computer Science & Information Technology

You might also like to view...

Case-Based Critical Thinking QuestionsCase 1-3Your colleague Gina, who has been at the firm for a few months longer than you, offers to give you information about the various views available in Project so that you can determine which of the following will best serve your needs.You need to know whether a task is on the critical path. What does Gina recommend to you?

A. Schedule Table B. Tracking Table C. Summary Table D. Variance Table

Computer Science & Information Technology

An index may be added to or deleted from tables at any time except for primary key indexes.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The connection string  includes ____.

A. the data provider and the database name B. SQL statement to retrieve the data C. the type of database D. an open statement

Computer Science & Information Technology

Since all programs and data are accessed from and stored on the portable computer’s storage hardware, a ____ or notebook stand lets you use the same portable computer at home and on the road, while still having a comfortable work environment at home.

A. notebook holder B. tablet PC stand C. docking station D. laptop station

Computer Science & Information Technology