Write a Java-program to Count the number of letters in a given string ?

Write a Java-program to Count the number of letters in a given string ?

Write a Java-program to Count the number of letters 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();
		ch = s.toCharArray();
		for(x=0;x<n;x++)
		{
			if(Character.isLetter(ch[x]))
			{
				count++;
			}
		}
		System.out.println("Number of letters  are "+count);

	}

}


Output:

Enter String : sateesh@123
Number of letters are 7





More Questions


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 ?
12 . Write a Java-program to Remove numbers in a given string ?
13 . Write a Java-program to print duplicate characters from the string ?
14 . Write a Java-program to print unique(distinct (or non-repeating characters) ) characters from the string ?
15 . Write a java program How to check if two strings are anagrams of each other?