I'm a bit stuck on how I should replace each element in char array to a number.
Here's the code I have so far:
public static void main(String []args){
String[] dialTwo = {"a", "b", "c"};
String[] dialThree = {"d", "e", "f"};
String[] dialFour = {"g", "h", "i"};
String[] dialFive = {"j", "k", "l"};
String[] dialSix = {"m", "n", "o"};
String[] dialSeven = {"p", "q", "r", "s"};
String[] dialEight = {"t", "u", "v"};
String[] dialNine = {"w", "x", "y", "z"};
Scanner in = new Scanner(System.in);
System.out.print("Enter a phone number: ");
String phoneInput = in.next();
char[] inputToArray = phoneInput.toCharArray();
while (!phoneInput.matches("^[a-pA-P0-9]*$")) {
System.out.println("Not a valid number. Try agian.");
phoneInput = in.next();
}
I was able to successfully verify the string in case someone wanted to enter ;;';';.
Thank you for your help guys.
My teacher also wants me to use method classes, but I'm slightly confused on it so I'm doing it a bit differently.
So the output I want, if someone were to input "CFG" it would print 123.