private void convertToNumeric() {
for (int i = 0; i < this.CONVERT_TO_NUMERIC.length; i++) {
for (int j = 0; j < this.INPUT_FROM_USER.length(); j++) {
}
}
}
private String INPUT_FROM_USER = "";
private final String[][] CONVERT_VALUES = { {"1", "w"}, { "2", "e"}, {"3", "r"},
{"4", "s"}, {"5", "d"}, {"6", "f"}, {"7", "z"},
{ "8", "x"}, {"9", "c"} };
private final String[][] CONVERT_TO_NUMERIC = { {"abc", "2"}, {"def", "3"}, {"ghi", "4"},
{"jkl", "5"}, {"mno", "6"}, {"pqrs", "7"},
{"tuv", "8"}, {"wxyz", "9"} };
Can someone please give me some guidance on how I'd go about converting an input to the character specified in the String arrays?
Here's an example.
- User inputs "Hello world"
- Searches the String array and converts each character in the String to the given number
- Outputs "43556 96753"
If the first value of the array contains the character, it will get replaced with the number.
I'm not asking to be spoonfed, I just need a little guidance on how to get started. Thanks in advance.