wap to accept a word. count all the alphabets excluding vowels present in word and display the result
Answers
Answered by
4
import java.util.*;
class Count
{
static void main()
{
Scanner sn = new Scanner(System.in);
System.out.print("Enter a word: ");
String s=sn.readLine();
int n = s.length();
int i, c=0;
char ch;
for(i=0;i<=n-1; i++)
{
ch=s.characterAt(i);
if(ch!='a'||ch!='e'||ch!='i'||ch!='o'||ch!='u'||ch!='A'||ch!='E'||ch!='I'||ch!='O'||ch!='U')
{
c++;
}
}
System.out.print("Total consonant alphabets : "+c);
}
}
class Count
{
static void main()
{
Scanner sn = new Scanner(System.in);
System.out.print("Enter a word: ");
String s=sn.readLine();
int n = s.length();
int i, c=0;
char ch;
for(i=0;i<=n-1; i++)
{
ch=s.characterAt(i);
if(ch!='a'||ch!='e'||ch!='i'||ch!='o'||ch!='u'||ch!='A'||ch!='E'||ch!='I'||ch!='O'||ch!='U')
{
c++;
}
}
System.out.print("Total consonant alphabets : "+c);
}
}
prakriti27:
pls!! mark it as the best...
Similar questions