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);
}
}
foreach?Iterator), but that would be an overkill for this task.