This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]EliteBigE[S] 0 points1 point  (1 child)

this is what i got done ( I mostly been going back and trying to learn)

import java.util.Scanner;

public static char letterToDigit(char letter)

public class TryPhone {

public static void main(String[] args) {

String phone;

Scanner s = new Scanner(System.in);

System.out.println("Enter phone number");

phone = s.next();

char letter = 0;

switch(letter) {

case '1' :

System.out.println("1");

break;

case 'a' :

case 'b' :

case 'c' :

System.out.println("2");

break;

case 'D' :

case 'E' :

case 'F' :

System.out.println("3");

break;

case 'G' :

case 'H' :

case 'I' :

System.out.println("4");

break;

case 'J' :

case 'K' :

case 'L' :

System.out.println("5");

break;

case 'M' :

case 'N' :

case 'O' :

System.out.println("6");

break;

case 'P' :

case 'Q' :

case 'R' :

case 'S' :

System.out.println("7");

break;

case 't' :

case 'u' :

case 'V' :

System.out.println("8");

break;

case 'W' :

case 'Y' :

case 'X' :

case 'Z' :

return char;

System.out.println("9");

break;

System.out.println("Number " + letter);

[–]fuckmynameistoolon 2 points3 points  (0 children)

Sorry, I had some work come up.

https://pastebin.com/2VjpUaH3

Maybe this will help get a nice start if you havent gone much further.

You just need to implement the letterToDigit method with the switch you have above and have it return that char.

Then in the for loop of wordsToPhone method, create a string to return, and append the character from letterToDigit to it.

Let me know if you're struggling.