# Developing a program that inputs telephone numbers

• 01-26-2014, 01:49 AM
chrismb
Developing a program that inputs telephone numbers
Develop an algorithm for a Java program that takes as input a single letter and displays the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way: 2 = ABC 3 = DEF 4 = GHI 5 = JK 6 = MNO 7 = PQRS 8 = TUV 9 = WXYZ

The screen dialog might look like this: Enter a single letter, and I will tell you what the corresponding digit is on the telephone. R The digit 7 corresponds to the letter R on the telephone.

The program should display a message indicating that there is no matching digit for any non-alphabetic character entered by the user. Also, the application should recognize only uppercase letters. If a user enters a lowercase letter, the program should display an error message. Prompt the user with an informative message for the input value as shown above.

The application should include the input letter as part of the output.

Write the algorithm to solve this problem including steps for prompting the user, getting input from the keyboard, and displaying the results.

Write the Java program that you designed, using your algorithm as a guide. Use your algorithm as comments in the body of the main method.

Use proper indentation, and meaningful identifiers throughout the code.
• 01-26-2014, 01:50 AM
chrismb
Developing a program that inputs telephone numbers
Develop an algorithm for a Java program that takes as input a single letter and displays the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way: 2 = ABC 3 = DEF 4 = GHI 5 = JK 6 = MNO 7 = PQRS 8 = TUV 9 = WXYZ

The screen dialog might look like this: Enter a single letter, and I will tell you what the corresponding digit is on the telephone. R The digit 7 corresponds to the letter R on the telephone.

The program should display a message indicating that there is no matching digit for any non-alphabetic character entered by the user. Also, the application should recognize only uppercase letters. If a user enters a lowercase letter, the program should display an error message. Prompt the user with an informative message for the input value as shown above.

The application should include the input letter as part of the output.

Write the algorithm to solve this problem including steps for prompting the user, getting input from the keyboard, and displaying the results.

Write the Java program that you designed, using your algorithm as a guide. Use your algorithm as comments in the body of the main method.

Use proper indentation, and meaningful identifiers throughout the code.
• 01-26-2014, 02:38 AM
Norm
Re: Developing a program that inputs telephone numbers
• 01-26-2014, 12:26 PM
zFollette
Re: Developing a program that inputs telephone numbers
Are you really trying to get someone to write this for you?
• 01-26-2014, 03:01 PM
SurfMan
Re: Developing a program that inputs telephone numbers
• 01-26-2014, 06:07 PM
AlexGraal
Re: Developing a program that inputs telephone numbers
Well, if you actually want help, go google these:

java.util.Scanner

switch statements

forloops

Should get you what you need.

In a forloop, ask for first letter, then save it to a char. Use a switch statement with cases to turn it into numbers.

If you actually want a finished code - go home. You won't get one.
• 01-26-2014, 06:33 PM
JosAH
Re: Developing a program that inputs telephone numbers
I'd build something around this:

Code:

```String key= "ABCDEFGH ..."; int[] val= { 2, 2, 2, 3, 3, 3 ... };```
kind regards,

Jos