Write a program to accept a line and check how many consonants and vowels are there in line
/*Write a program to accept a line and check how many consonants and vowels are there in line*/
import java.util.Scanner;
class Line
{
public static void main(String args[])
{
int i,count=0,n=0;
Scanner a=new Scanner(System.in);
System.out.println("enter string=");
String s=a.nextLine();
int b=s.length();
for(i=0;i<b;i++)
{
char c=s.charAt(i);
if (c=='i' || c=='a' || c=='e' || c=='o'|| c=='u' )
{
count=count+1;
}
else
n++;
}
System.out.println("number of vowels=" + count);
System.out.println("number of consonant=" +n);
}
}
import java.util.Scanner;
class Line
{
public static void main(String args[])
{
int i,count=0,n=0;
Scanner a=new Scanner(System.in);
System.out.println("enter string=");
String s=a.nextLine();
int b=s.length();
for(i=0;i<b;i++)
{
char c=s.charAt(i);
if (c=='i' || c=='a' || c=='e' || c=='o'|| c=='u' )
{
count=count+1;
}
else
n++;
}
System.out.println("number of vowels=" + count);
System.out.println("number of consonant=" +n);
}
}
Comments
Post a Comment