import java.util.*;
class Frequency
{
int i;
String str,s,word,str1="";
Scanner sc=new Scanner(System.in);
public void take()
{
System.out.print("\nEnter the sentence:");
str=sc.nextLine();
str=str+" ";
System.out.print("\nEnter the word to be removed:");
word=sc.nextLine();
while(true)
{
i=str.indexOf(' ');
if(i<0)
break;
s=str.substring(0,i);
str=str.substring(i+1);
if(!s.equals(word))
str1=str1+ " " + s;
}
str1=str1.trim();
System.out.print("\nModified Sentence is: "+str1);
}
public static void main(String args[])
{
Frequency ob=new Frequency();
ob.take();
}
}
No comments:
Post a Comment