Can anyone plzz give me the java coding for converting the string 'REPUBLIC DAY IS CELEBRATED ON 26 JANUARY' to 'INDEPENDENCE DAY IS CELEBRATED ON 15 AUGUST'. With scanner class.
aryan014:
plz don't copy from google. I want self written prog
Answers
Answered by
1
hello....!!
import java.io.*;
public class Replace
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a string: ");
String a=br.readLine();
String ans;
do
{
System.out.print("Enter the word to be found: ");
String find=br.readLine();
System.out.print("....................... : ");
String repl=br.readLine();
a=a.replace(find,repl);
System.out.print("Continue? (y/n): ");
ans=br.readLine();
}
while(ans.equalsIgnoreCase("y"));
System.out.println(a);
}
}
import java.io.*;
public class Replace
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a string: ");
String a=br.readLine();
String ans;
do
{
System.out.print("Enter the word to be found: ");
String find=br.readLine();
System.out.print("....................... : ");
String repl=br.readLine();
a=a.replace(find,repl);
System.out.print("Continue? (y/n): ");
ans=br.readLine();
}
while(ans.equalsIgnoreCase("y"));
System.out.println(a);
}
}
Similar questions