Menu

[solved] – Question 8881

Write a class TelephoneNumber that will hold a telephone number. An object of this class will have attributes .. areaCode—a three-digit integer,exchangeCode—a three-digit integer,number—a four-digit int
and the methods
1.TelephoneNumber(aString)—a constructor that creates and returns a new instance of its class xxx–xxx–xxxx or,if the area code is missing, xxx–xxxx. Throw an exception if the format is not valid Hint 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.)
2 .toString—returns a string in either of the two formats shown previously for the contructor.ae
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,creates an array whose base type is Telephone Number.allow the user to

Expert Answer


OR


Leave a Reply

Your email address will not be published. Required fields are marked *