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);
}  
}               
   

Comments

Popular posts from this blog

Write a java program to calculate gross salary & net salary taking the following data

WAP a program that illustrates interface inheritance. Create two interface p1 and p2 . create Interface p which extends p1 and p2 and then create interface p12 which extends p12. Each interface declare one constants and one method. Create class Q which implements p12 and define all the methods of interface which displays value of constants

WAP that create interface on that you declare one method interest(p,r,n) then create two class simple and compound that implements interest and find simple and compound interest.