このコードで何が問題なのかわかりません。私が入力として提供するものであれば、コードはiを出力として出力します。どんな助けもありがとうございます。ほとんどの母音を含む単語を印刷するプログラム
public class VowelClass{
public static void main(String args[]){
String input;
System.out.println("Please enter your sentence: ");
Scanner scan = new Scanner(System.in);
input = scan.nextLine();
int maxVCount = 0;
String mostVowels = null;
String[] words = input.split("");
for (String word : words) {
int vCount = 0;
word = word.toLowerCase();
for (int i=0; i<word.length(); i++){
char x = word.charAt(i);
if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'){
vCount++;
}
}
if (vCount > maxVCount) {
maxVCount = vCount;
mostVowels = word;
}
}
System.out.println("Word with most vowels is:");
System.out.println(mostVowels);
}
}
'input.split(" ")'を 'input.split(" ");に変更できますか? – Orin
ありがとう!あたかも恥ずかしがり屋であった – wibwaj
将来的には、健全性チェックの目的で、出力、つまり 'System.out.println(word);のデバッグやSOPゲーティングを試みてください。タイプミスを見つける最速の方法。 – Compass