Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab5;
- import java.util.Scanner;
- public class task1 {
- public static int countVowels(String args) {
- int vwlCNT=0;
- String arg =args.toLowerCase();
- for(int i=0;i<arg.length();i++) {
- if (arg.charAt(i) == 'a' || arg.charAt(i) == 'e' || arg.charAt(i) == 'i'
- || arg.charAt(i) == 'o' || arg.charAt(i) == 'u') {
- vwlCNT++;
- }
- }
- if(vwlCNT==0)return 0;
- else
- return vwlCNT;
- }
- public static void main(String[] args) {
- Scanner ac=new Scanner(System.in);
- System.out.println("enter the name or sentence ");
- String name=ac.nextLine();
- int number = countVowels(name);
- System.out.println(" total number of vowles are = "+number);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement