A+ Work





In this lab you will write a program that simulates the dialing of a phone number. The phone number may have either digits, letters, or both. (See sample output below) Here are the letters associated with each digit.





0 5 J K L 

1 6 M N O 

2 A B C 7 P Q R S 

3 D E F 8 T U V 

4 G H I 9 W X Y Z 



If the phone number entered does not have one of the valid digits or valid letters, display an error message. Write a method to convert the letter to a digit and to determine if it is valid.



A phone number never begins with a 0, so the program should flag an error if such a number is entered. Also a phone number never begins with 555, so the program should flag an error if such a number is entered. A phone number always has a hyphen (-) in the 4th position. Display an error message if it is not. If a hyphen is in any other position, it is considered an invalid digit and display an error message. 



Use the switch statement wherever possible. Use Console.Read to input one character at a time from the keyboard buffer. Your output needs to look like mine.



Sample Output from Program - Each 3 lines is one run of the program.



Enter a phone number: s&i-oiem

Digit 2 is invalid

Press any key to continue . . .



Enter a phone number: asn-fgtr

Phone Number Dialed: 276-3487

Press any key to continue . . .



Enter a phone number: 0io-9876

Phone number cannot begin with a 0

Press any key to continue . . .



Enter a phone number: jkl-oiuy

Phone number cannot begin with 555

Press any key to continue . . .



Enter a phone number: asdfghjk

Digit 4 must be a hyphen

Press any key to continue . . .