Q:

Return numbers from String input, Java

I am kind of stumped here and have been trying to figure this out for some time. This is homework, although I want to learn to code regardless. Here I have to convert the string input by the user to uppercase letters, then those uppercase letters to numbers using the phone keypad system(2 = ABC etc.). 
I have gotten this far but am unsure as to what my next step should be. Any ideas are greatly appreciated, thanks in advance.
package chapter_9;

import java.util.Scanner;

public class Nine_Seven {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter a string: ");
        String s = input.next();

        // unsure what to do here, know i need some sort of output/return
        // statement
    }

    public static int getNumber(char uppercaseLetter) {
        String[] Keypad = new String[10];
        Keypad[2] = "ABC";
        Keypad[3] = "DEF";
        Keypad[4] = "GHI";
        Keypad[5] = "JKL";
        Keypad[6] = "MNO";
        Keypad[7] = "PQRS";
        Keypad[8] = "TUV";
        Keypad[9] = "WXYZ";

        for (int i = 0; i < Keypad.length; i++) {
            // unsure what to do here
        }

        return (uppercaseLetter);
    }
}

A:

To get the number for a char, you should probably do your array the other way around.  You method could look like this:
public static int getNumber(char uppercaseLetter) {
    int[] keys = {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9};
    return keys[(int)uppercaseLetter - 65];  //65 is the code for 'A'
}

It may also be a good idea to pull the keys array into a member variable for the class so that you don't initialise it on every call.
As for the output/conversion, I suggest you have a look at java.lang.System class.  Also note that you haven't converted the string to uppercase - and are not checking for the validity of input (that it's a string made from just the 26 letters).

