Write a Java-program to Count number of Consonants in a given string

Write a Java-program to Count number of Consonants in a given string

Write a Java-program to Count number of Consonants in a given string

Program
import java.util.Scanner;
public class Main 
{

	public static void main(String[] args) 
	{
		int x,n,count=0;
		String s;
		char ch;
		Scanner sc=new Scanner(System.in);
		System.out.println("Enter String :");
		s=sc.nextLine();
		n=s.length();
		for(x=0;x<n;x++)
		{
			ch=s.charAt(x);
			if(!(ch=='a'|| ch=='e' || ch=='i'|| ch=='o'||ch=='u' || ch=='A'|| ch=='E' || ch=='I'|| ch=='O'||ch=='U'))
			{
				count++;
			}
		}
		System.out.println("Number of Vowels are : "+count);

	}

}
	

Output:

Enter String : sateesh
Number of Vowels are: 4





More Questions


2 . Write a Java-program to Count the number of Consonants in a given string ?
3 . Write a Java-program to Count the number of spaces in a given string
4 . Write a Java-program to Count the number of special characters in a given string ?
5 . Write a Java-program to Count the number of letters in a given string ?
6 . Write a Java-program to Count the number of Numbers in a given string ?
7 . Write a Java-program to Remove vowels in a given string ?
8 . Write a Java-program to Remove consonants in a given string ?
9 . Write a Java-program to Remove special characters in a given string ?
10 . Write a Java-program to Remove spaces in a given string ?
11 . Write a Java-program to Remove letters in a given string ?