Question: Task 4 (25 pts.) Create project: HW2_PhoneNumber Submit java file: HW2_PhoneNumber.java A phone number has the format (xxx)yyy-zzzz ( e.g.(817)272-7227 ). Write a program that

Task 4 (25 pts.)

Create project: HW2_PhoneNumber Submit java file: HW2_PhoneNumber.java A phone number has the format (xxx)yyy-zzzz ( e.g.(817)272-7227 ). Write a program that reads a string and formats it as a phone number. First it should check that the string has exactly 10 symbols. If it does, the program will print the formatted version. If the string does not have exactly 10 symbols, print Invalid and do not process it. You do NOT need to verify that the symbols in the string are digits.

---- Sample run 1 This program will format a string as a phone number. Enter the number: 8177263333 Formatted number: (817)726-3333 Bye. ---- Sample run 2 This program will format a string as a phone number. Enter the number: 621587 Not a valid number. Please enter another one: 8172727229 Formatted number: (817)272-7229 Bye. ---- Sample run 3 This program will format a string as a phone number. Enter the number: 653218 Not a valid number. Please enter another one: 12389128790870328974912 You missed your second try! No more chances! Bye.

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!