# Program to count letter, Digit, Special Char, Blank Space in a sentence

- Link: https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/
- Published: 2018-11-03T22:25:04+05:30
- Author: Ashishkumar Vishwakarma

In this we learn Program to count letter, Digit, Special Char, Blank Space in a 
sentence

## Program to count letter, Digit, Special Char, Blank Space and Words in the sentence

    ```language-dotnet
    import java.io.*;
    class Space{
    public static void main(String args[]) throws IOException
    {
    	String s; //Declaration os String varible to read the sentence
    	BufferedReader r=new BufferedReader(new 	 
            InputStreamReader(System.in));//assigning new input method
    	System.out.println("Enter the sentence"); //prompt the user to 
             enter the sentence
    	s=r.readLine(); //Read the user entered sentence into variable 
    	int i=1; //for count of loop
    	int a=0; //For count of alphabet
    	int d=0; //For count of digit
    	int sc=0; //For count of special character
    	int bs=0; //For count of blank spaces
    	int w=1; //For count of words
    	char ch; //For a single character of sentence
    	int l=s.length(); //String length of sentence in variable l
    	for(i=0;i<l;i++)
    	{
    		ch=s.charAt(i);
    		if(Character.isLetter(ch) )
    			++a;
    		else
    		if(Character.isDigit(ch))
    			++d;
    		else
    		if(ch==' ')
    			++bs;
    		else
    			++sc;
    	}
    	System.out.println("There are "+a+" Alphabet");
    	System.out.println("There are "+d+" Digit");
    	System.out.println("There are "+sc+" Special Character");
    	System.out.println("There are "+bs+" Blank Spaces");
    	for(i=0;i<l;i++)
    	{
    		if(s.charAt(i)==' ')
    			w++;
    	}
    	System.out.println("There are "+w+" Word");
    }//END OF MAIN
    }//END OF CLASS
    ```

#### OUTPUT.

> C:\A>javac Space.java
> C:\A>java SpaceEnter the sentenceJanuary2018 #$ ,There are
> 7 AlphabetThere are 4 DigitThere are 3 Special CharacterThere are 2 Blank SpacesThere
> are 3 Word

Also, you can use the Java [compiler](https://www.onlinegdb.com/online_java_compiler)
to compile a program.

Also, View:[ – Write a program to create a registration form using AWT](https://technotaught.com/registration-form/).

### Share this:

 * [  X ](https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/?share=twitter)
 * [  Facebook ](https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/?share=facebook)
 * [More](https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/#)

 * [  WhatsApp ](https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/?share=jetpack-whatsapp)
 * [  LinkedIn ](https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/?share=linkedin)
 * [  Email ](https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/?subject=%5BShared%20Post%5D%20Program%20to%20count%20letter%2C%20Digit%2C%20Special%20Char%2C%20Blank%20Space%20in%20a%20sentence&body=https%3A%2F%2Ftechnotaught.com%2Fprogram-to-count-letter-digit-special-char-blank-space-in-a-sentence%2F&share=email)
 * [  Reddit ](https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/?share=reddit)
 * [  Tumblr ](https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/?share=tumblr)
 * [  Pinterest ](https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/?share=pinterest)
 * [  Telegram ](https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/?share=telegram)
 * [  Print ](https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/#print?share=print)

### _Related_

## Comments

### By: pharmacy online

- Link: https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/#comment-152
- Published: 2020-10-07T23:58:43+05:30

I think this is the best post till now

### By: https://kauviagra.com/

- Link: https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/#comment-150
- Published: 2020-10-05T22:45:02+05:30

Thanks a lot

### By: Steph B

- Link: https://technotaught.com/program-to-count-letter-digit-special-char-blank-space-in-a-sentence/#comment-128
- Published: 2020-04-22T07:34:54+05:30

Your method of explaining the whole thing in this post is, in fact, pleasant, every
one be capable of effortlessly be aware of it, Thanks a lot.
