Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to separate out a phone number when it is given with colon’s sep

ID: 3634142 • Letter: W

Question

Write a program to separate out a phone number when it is given with colon’s separating the sections.

Directions
Points

The file must be called <YourNameProg1.java> (driver program)
<YourInitialsDissector.java> (Dissector class file)

Example:
KenDeweyProg1.java (driver program)
KDDissector.java (dissects the phone number into sections)

Ensure you include ALL files required to make your program compile and run.
I would like to see your .java files only.

Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter.
5%

Style Requirements

Refer to the Java Coding Style Document in Doc Sharing.
Comments are required for all files including the driver.
10%

Overall Requirements

Every phone number is broken up into sections as shown below:



Country Code
Area Code
Prefix
Line Number

1
919
882
5000




Explanation / Answer

* SKDissector.java 03 * Stephanie Krahnke 04 * 05 * This program dissects a phone number into its individual pieces. 06 ******************************************************************/ 07 08 public class SKDissector 09 { 10 String colonSeparated; //string holding the entire phone number separated by colons 11 String countryCode; //country code of a phone number 12 int areaCode; //area code of a phone number 13 int prefix; //prefix numbers in a phone number 14 int number; //last four digits of a phone number 15 16 17 public SKDissector(String colonSeparated) 18 { 19 this.colonSeparated = colonSeparated; 20 } // end constructor 21 22 23 public String getPhoneNumber() 24 { 25 return this.colonSeparated; 26 27 }//end getPhoneNumber 28 29 public String getPhoneNumber(1) 30 { 31 countryCode = colonSeparated.subString(0,colonSeparated.indexOf(':')); 32 } 33 34 public String getPhoneNumber(2) 35 { 36 String tempAreaCode = colonSeparated.subString(countryCode + 1,colonSeparated.indexOf(':')); 37 areaCode = Integer.parseInt(tempAreaCode); 38 } 39 40 public String getPhoneNumber(3) 41 { 42 String tempPrefix = colonSeparated.subString(areaCode + 1,colonSeparated.indexOf(':')); 43 prefix = Integer.parseInt(tempPrefix); 44 } 45 46 public String getPhoneNumber(4) 47 { 48 String tempNumber = colonSeparated.subString(colonSeparated.lastIndexOf(':')); 49 number = Integer.parseInt(tempNumber); 50 } 51 52 53 }//end SKDissector

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote