Wednesday, October 10, 2018

BlueJ Program on Letter or Digit Checking in a sentence



import java.io.*;
class LetterCh
{
  BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
int I,len,c=0;
char ch;
public void showLettersDigits () throws Exception
{
 System.out.print("\nEnter the sentence:");
String str=br.readLine();
str=str.trim();
len=str.length ();
for (i=0;i< len;i++)


{
ch= str.charAt(i);
if(Character.isLetterOrDigit(ch))
c++;
}
System.out.print(“Total number of Letters and Digits in the sentence=”+c);
}

public static void main(String args[])
{
LetterCh ob=new LetterCh ();
ob. showLettersDigits();
}
}


Related Post: Programs on Character Class

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner