Sie sind auf Seite 1von 2

public class Count1

{
public static void main (String args[])
{

int i = 0;
int count = 0;

int counter = 0;
int nextvowel_counter = 0;
// String input = "aaaaeeaaiieeoiiouuuuaa";
String input = "aaeiioeaouu"; //input
int len = input.length();
String vowels = "aeiou "; //defining vowels to compare it with the
input string

System.out.println("The length of the string"+" "+input+" "+"is"+"


"+len); //total length of input string

if(vowels.charAt(0)==input.charAt(0))
{
count = 1;
}

else
{
count = 0;
}

int vowelincrement =0 ;
int flag =1;
for(i=0;i<=len-1;i++) //iterate the loop till the end of characters in the
input string A

if(vowels.charAt(vowelincrement)==input.charAt(i) )
{
flag=1;
counter++;

}else if(vowels.charAt(vowelincrement+1) == input.charAt(i)){

vowelincrement++;
counter++;
}

else if(flag == 1)
{
for(int vcount = 0; vcount<vowelincrement ; vcount++){
if(vowels.charAt(vcount)==input.charAt(i))
{
vowelincrement++;
flag =0;
break;
}
}

System.out.println("The magic number is"+" "+counter);

Das könnte Ihnen auch gefallen