I need to write a program that reads any character from user input. The program
ID: 3632655 • Letter: I
Question
I need to write a program that reads any character from user input. The program is then instructed to return either null or the numbers in a phone number format. The only valid digits the program will accept should be whitespace ("space" or " ") and the hyphen (-). Ultimately, however, the program will return the digits in phone number format. Any other character will result in the program returning null, and having to ask the user to enter a valid input. The program should only accept a 10 digit number. Examples of valid inputs are:1234567890 //exactly ten digits
212-433-1999 //hyphens are accepted
2 5 7 2 6 8 9 1 0 1 // spaces are accepted
2-7-899912 36 //hyphens are spaces are sporadic, but still valid as it is programmed to accepted hyphens and space. it also has 10 digits
the output should look like this:
123-456-7890
212-433-1999
257-268-9101
278-999-1236
//notice they all come out as phone number format.
here are examples of invalid inputs:
(360)710-2638 //not programmed to accept parenthesis
nine one six (627)-9735 //not programmed to accepted these characters
916-619-916 //only nine digits, it must be ten digits long.
any invalid input should return a null value.
thanks for all the help guys.