Question: IN JAVA Create the skeleton of a program named PhoneNumber. Write code that prompts the user to enter a phone number in the proper format

IN JAVA

Create the skeleton of a program named PhoneNumber.

Write code that prompts the user to enter a phone number in the proper format and reads the input as a string. (Refer to sample output below.)

Create a loop to validate the phone number input using the String method matches. If the entry is invalid, inform the user of the error and prompt for and read a new user input.

Implement String methods split and substring in your code when separating the phone number into its parts (3-digit area code, first 3 digits of the number, and last 4 digits of the number). Hint: You will need to use the correct delimiter characters during the tokenization process.

Create separate String variables to store areaCode (3 digits) and number (7 digits created by concatenating the last two tokens of the phone number).

The final program output displays the area code and the seven-digit phone number.

Output should reflect:

 IN JAVA Create the skeleton of a program named PhoneNumber. Write

Enter a phone number with the format (555) 555-5555: Invalid input. Enter a phone number with the format (555) 555-5555: 123 456 7890 Invalid input. Enter a phone number with the format (555) 555-5555: (123) 456 78901 Invalid input. Enter a phone number with the format (555) 555-5555: (222) 333-4444 Area Code: 222 Phone Number: 3334444

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!