Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

BlueJ Program on Removing all punctuations special characters from a sentence


In this program the user will enter a sentence and all the punctuations and special characters
in the string will be removed.
Example
Input: This is, a test
Output: This is a test               

import java.io.*;
class A
{
 String s1,s2;
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
 int i,len;
 char ch;
 public void take () throws Exception
 {
  System.out.println("Enter the sentence:");
  s1=br.readLine();
  len=s1.length();
  s2="";
  for(i=0;i< len;i++)
  {
  ch=s1.charAt(i);
 if(Character.isLetter(ch)|| Character.isDigit(ch)||ch==' ')
  s2=s2+ch;
  }
 System.out.println("Original sentence="+s1);
 System.out.println("Modified sentence="+s2);
 }
 public static void main(String args[])throws Exception
 {
 A ob=new A();
 ob.take();
 }
 }


This post first appeared on Tutorial Site On Computer Programming Languages F, please read the originial post: here

Share the post

BlueJ Program on Removing all punctuations special characters from a sentence

×

Subscribe to Tutorial Site On Computer Programming Languages F

Get updates delivered right to your inbox!

Thank you for your subscription

×