need help immediately with this code
807599Mar 18 2007 — edited Mar 18 2007hi, every i' m very new to here and I 'm very new to java
i'm trying to do the volwel and consonants assignment
i don't know what is worng with my code
because it did not display the correct answer
so please anybody help
thank in advance
import java.util.Scanner;
public class VoCo
{
public static void main(String[] args)
{
String str;
int consonants =0;
int vowels=0;
int letter =0;
String Vol = "aeiou";
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter a string word: ");
str = keyboard.nextLine();
char[] array;
array=str.toCharArray();
for(int i=0; i< array.length; i++)
{
if(Character.isLetter(Vol.charAt(i)))
{
letter++;
if(Vol.indexOf(Vol.charAt(i))>=0)
{
vowels++;
}
else
consonants++;
}
}
System.out.println(" There are " + letter + " letter" );
System.out.println(" There are " + vowels + " vowels" );
System.out.println(" There are " + consonants + "consonants" );
}
}