我正在尝试调用 java 方法来确定用户输入的字母是元音还是辅音。不确定如何正确调用该方法。
import java.util.*;
public class HW8Problem1{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a letter: ");
String letter = input.nextLine();
}
public static void vowel(String a){
if (a.charAt(0) == 'a' || a.charAt(0) == 'A'){
System.out.println(" is a vowel");
if (a.charAt(0) == 'e' || a.charAt(0) == 'E')
System.out.println(" is a vowel");
if (a.charAt(0) == 'i' || a.charAt(0) == 'I')
System.out.println(" is a vowel");
if (a.charAt(0) == 'o' || a.charAt(0) == 'O')
System.out.println(" is a vowel");
if (a.charAt(0) == 'u' || a.charAt(0) == 'U')
System.out.println(" is a vowel");
else
System.out.println(" is a consonant");
}
}
}