Question: Java The is Name class of lab3.1, please use it as the guide Write the code of PhoneNumber class please, thank you! WorkArea Using the

JavaJavaThe is Name class of lab3.1, please use it as the guideWrite the code of PhoneNumber class please, thank you! WorkArea Using theThe is Name class of lab3.1, please use it as the guideName class of Lab 3.1 as a guide, code a PhoneNumber classand its associated main. The class should have the following state: -A single string, number and the following behavior: - methods getareaCode, getExchange,and getLineNumber that return the first three digits, the moddle three digits,

Write the code of PhoneNumber class please, thank you!

WorkArea Using the Name class of Lab 3.1 as a guide, code a PhoneNumber class and its associated main. The class should have the following state: - A single string, number and the following behavior: - methods getareaCode, getExchange, and getLineNumber that return the first three digits, the moddle three digits, and the last four digits respec. of the number - a method, isTollfree that returns true if the number is a toll-free phone number (i.e., the area code begins with an '8'). - tostring, equals, and read methods that correspond to their counterparts in the Name class. - A main method that performs similar logic to that of the Name class, i.e., - opens the file numbers.text - reads in PhoneNumber objects, using the read method of the class (until nu11 is returned). - prints out the PhoneNUmber object (using tostring) - prints out whether the number is tollfree - checks for adjacent duplicate numbers - keeps count of the number of PhoneNumbers read in The name of your class should be PhoneNumber. Please remove the public attribute from your class definition (CodeLab restriction). For example, if the file numbers.text contains: (356)1539460(290)2617625(761)3219457(724)0917819(759)3013133(072)0230203(060)0753782(060)0753782(369)3489660(844)8245853(692)8398466(216)3862922 the program should produce the following output: the program should produce the following output: phone number: (060)075-3782 is toll free: false phone number: (060)075-3782 area code: 060 exchange: 075 line number: 3782 is toll free: false Duplicate phone number "(060)075-3782" discovered phone number: (369) 348-9660 area code: 369 exchange: 348 line number: 9660 is toll free: false phone number: (844)824-5853 area code: 844 exchange: 824 line number: 5853 is toll free: true phone number: (692)839-8466 area code: 692 exchange: 839 line number: 8466 is toll free: false phone number: (216) 386-2922 area code: 216 exchange: 386 line number: 2922 is toll free: false 12 phone numbers processed. Additional Notes: - numbers.text should not be modified exchange: 348 line number: 9660 is toll free: false phone number: (844)824-5853 area code: 844 exchange: 824 line number: 5853 is toll free: true phone number: (692)839-8466 area code: 692 exchange: 839 line number: 8466 is toll free: false phone number: (216) 3862922 area code: 216 exchange: 386 line number: 2922 is toll free: false 12 phone numbers processed. Additional Notes: - numbers.text should not be modified Instructor Notes: [notes toc="Lab 3.2: A Phone Number Class (PhoneNumber)" nonum="yes"]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!