//program for extracting vowel from sentence using array
import java.io.*;
class vl1
{
public static void main(String args[])throws IOException
{
DataInputStream in = new DataInputStream(System.in);
System.out.println("enter the sentence");
String s=in.readLine();//stores the entered string in s
String tmp="",h="";
s=s.trim();
String g=s.toLowerCase();
g=g+" ";
int count=0,p=0,i;
int l=g.length();
try
{//for counting no.of spaces in the string entered
for( i=0;i<l;i++)
{
char ch=g.charAt(i);
if(ch==' ')
count+=1;
}
String d[]=new String[count];//array declaration with size
for(i=0;i<l;i++)
{
char ch=g.charAt(i);
if(ch!=' ')
tmp=tmp+ch;
else
{
d[p]=tmp;
p+=1;
tmp="";
}
}
int j;
//for printing vowels from the sentences
for( i=0;i<count;i++)
{
String m=d[i];
h="";
for(j=0;j<m.length();j++)
{ char x = m.charAt(j);
if(x=='a'||x=='i'||x=='e'||x=='o'||x=='u')
h=h+x;
}
System.out.println("Vowels in "+d[i]+"\t are: "+h);
}
}//try block ends
catch(ArrayIndexOutOfBoundsException e)//catching an exception
{
System.out.println(e);
}
}
}
import java.io.*;
class vl1
{
public static void main(String args[])throws IOException
{
DataInputStream in = new DataInputStream(System.in);
System.out.println("enter the sentence");
String s=in.readLine();//stores the entered string in s
String tmp="",h="";
s=s.trim();
String g=s.toLowerCase();
g=g+" ";
int count=0,p=0,i;
int l=g.length();
try
{//for counting no.of spaces in the string entered
for( i=0;i<l;i++)
{
char ch=g.charAt(i);
if(ch==' ')
count+=1;
}
String d[]=new String[count];//array declaration with size
for(i=0;i<l;i++)
{
char ch=g.charAt(i);
if(ch!=' ')
tmp=tmp+ch;
else
{
d[p]=tmp;
p+=1;
tmp="";
}
}
int j;
//for printing vowels from the sentences
for( i=0;i<count;i++)
{
String m=d[i];
h="";
for(j=0;j<m.length();j++)
{ char x = m.charAt(j);
if(x=='a'||x=='i'||x=='e'||x=='o'||x=='u')
h=h+x;
}
System.out.println("Vowels in "+d[i]+"\t are: "+h);
}
}//try block ends
catch(ArrayIndexOutOfBoundsException e)//catching an exception
{
System.out.println(e);
}
}
}
Comments