【发布时间】:2015-01-15 16:47:50
【问题描述】:
这是一个计算元音的代码。如何显示元音而不只是数它们?
System.out.println("Enter the String:");
String text = we.readLine();
int count = 0;
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (c=='a' || c=='e' || c=='i' || c=='o' || c=='u') {
count++;
}
}
System.out.println("The number of vowels in the given String are: " + count);
【问题讨论】:
-
你是如何显示消息
The number of vowels in the given String are:的? -
我什至不完全确定你在这里问什么。您想显示每个元音出现的次数吗?
-
而不是计算有多少元音,输出必须显示元音。例如“编程”元音是:o a i