Zählen Sie in Java die Vokale getrenntJava

Java-Forum
Anonymous
 Zählen Sie in Java die Vokale getrennt

Post by Anonymous »

Beispielausgabe: < /p>
Geben Sie eine Zeichenfolge ein:
Hallo < /p>
Eine Anzahl von jedem Vokal in der Zeichenfolge: < /p>
a: 0
e: 1
i: 0
o: 1
u: 0
other characters: 3
< /code>
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
int count = 0;
System.out.println("Enter a string: ");
Scanner myObject = new Scanner(System.in);
String anyWord = myObject.nextLine();

for (int i = 0; i < anyWord.length(); i++) {
char vowelA = anyWord.charAt(i);
if (vowelA == 'a' || vowelA == 'A') {
count++;
}
}
System.out.println("a: " + count);
}
}
< /code>
This is the code I am writing but I don't know what do to next...
Need your Help...

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post