Question: Write a program that will read alphanumeric words that are either 7 or 11 or more characters long. Each word will be white space terminated,
Write a program that will read alphanumeric words that are either 7 or 11 or more characters long. Each word will be white space terminated, ignore any characters after 11th. You are to output the phone number. You will be using the standard telephone keypad mapping. You will keep reading from standard input until EOF or a -1 has been entered.
| 0 = none (in some telephones, "OPERATOR" or "OPER") 1 = none 2 = ABC 3 = DEF 4 = GHI | 5 = JKL 6 = MNO 7 = PQRS 8 = TUV 9 = WXYZ |
Test Data Stream is a String String data = "1800Chargers ChargesRuleAlways\t22cs4bRules 1800xxxTPMJ 1cimw105SQLTakeIt aAEBxyz 582CS4A -1"; use Scanner in = new Scanner( data ); //for submit make sure its new Scanner( System.in );
Run: 1-800-242-7437 2-427-437-7853 2-227-427-8537 1-800-999-8765 1-246-910-5775 223-2999 582-2742
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
