I was wondering, beyond the standard improvements that this needs, is there a more clever way of solving this problem?The problem is to translate letters into digits without changing the format of the original string. The conversion is based on the international standard letter/number mapping on phones (i.e. where ABC is 2, DEF is 3, ..., PQRS is 7, TUV is 8, and WXYZ is 9).public class Keypad {    public static void main(String[] args) {        Scanner input = new Scanner(System.in);        System.out.print(Enter a string: );        String s = input.nextLine();        System.out.println(getNumbers(s));    }    public static String getNumbers(String s) {        String result = new String();        //Read and append s onto result        for (int i = 0; i < s.length(); i++) {            if (Character.isLetter(s.charAt(i))) {            result += getNumber(Character.toUpperCase(s.charAt(i)));            }            else {                result += s.charAt(i);            }        }        return result;    }    public static int getNumber(char upperCaseLetter) {        int number = ((upperCaseLetter - 'A') / 3) + 2;        if (number < 7) {            return number;        }        else if (upperCaseLetter - 'A' < 20) {            return 7;        }        else if (upperCaseLetter - 'A' < 23) {            return 8;        }        else {            return 9;        }    }}
Phone keypad implementation
java;beginner;strings