0
import java.io.*;

class InputDiagnosis{

      public static void main(String args[]) throws IOException
      {
         char ch;
         int digit=0;
         int upper=0;
         int lower=0;
         int other=0;

         BufferedReader inputstream =new BufferedReader(new InputStreamReader(System.in));

         System.out.println(" Type some text. When done, press Enter to Quit:");


         do{

          ch=(char) inputstream.read();

          if(Character.isDigit(ch))
            digit++;
          else if(Character.isUpperCase(ch))
            upper++;
          else if(Character.isLowerCase(ch))
            lower++;
          else
            other++;

          }while(ch !=' ');


          System.out.println("No Of Digits:" +digit);
          System.out.println("No Of Uppercase Characters:" +upper);
          System.out.println("No Of Lowercase Characters:" +lower);
          System.out.println("No Of Other Characters:" +other);

         }
     }

Edited by mike_2000_17: Fixed formatting

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by abhishek20
0

Try

while(ch != '\n');

in the while condition because you do not have any space in your input stream

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.