java:33 cannot find symbol
symbol: variable letter
in the line with System.out.println(getNumber(letter.charAt(0)));
If I remove the main method, the code will compile without errors. How can I get the main method to pull from the getNumbers and give me a result?
import java.util.*;
public class telephone2 {
public static int getNumber(char uppercaseLetter) {
if (letter=='A' || letter=='B' || letter== 'C') {
return 1;
}
else if(letter=='D' || letter=='E' || letter== 'F') {
return 2;
}
else if (letter=='G' || letter=='H' || letter== 'I') {
return 3;
}
else if (letter=='J' || letter=='K' || letter== 'L') {
return 4;
}
else if (letter=='M' || letter=='N' || letter== 'O') {
return 5;
}
else if (letter=='P' || letter=='Q' || letter== 'R' || letter== 'S') {
return 6;
}
else if (letter=='T' || letter=='U' || letter== 'V') {
return 7;
}
else if (letter=='W' || letter=='X' || letter== 'Y' || letter== 'Z') {
return 9;
}
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter alphanumeric phone number to convert to all numbers.");
String phoneNumber = input.nextLine();
System.out.println(getNumber(letter.charAt(0)));
}
}
(I have searched and looked through some of the previous questions about this specific program, but was unable to find an answer to my problem.) Thanks

New Topic/Question
Reply




MultiQuote









|