Advertisement
Huntersazzad

lab5_task1

Oct 29th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package lab5;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class task1 {
  6.      
  7.     public static  int countVowels(String args) {
  8.         int vwlCNT=0;
  9.         String arg =args.toLowerCase();
  10.         for(int i=0;i<arg.length();i++) {
  11.             if (arg.charAt(i) == 'a' || arg.charAt(i) == 'e' || arg.charAt(i) == 'i'
  12.                     || arg.charAt(i) == 'o' || arg.charAt(i) == 'u') {
  13.              vwlCNT++;
  14.             }
  15.            
  16.         }
  17.         if(vwlCNT==0)return 0;
  18.         else
  19.         return vwlCNT;
  20.          
  21.       }
  22.    
  23.     public static void main(String[] args) {
  24.         Scanner ac=new Scanner(System.in);
  25.         System.out.println("enter the name or sentence ");
  26.         String name=ac.nextLine();
  27.         int number = countVowels(name);
  28.         System.out.println(" total number of vowles are = "+number);
  29.        
  30.        
  31.  
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement