Computer Science, asked by aryan014, 1 year ago

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
kvnmurty: Aryan. . please ask another question for this problem in which someone may use the scanner class
aryan014: ok
aryan014: bt why?
kvnmurty: Because you wanted the code using the scanner class.
MacTavish343: I'll give you!!
MacTavish343: bt I'm busy right now coz tomorrow ia mine exam !!
MacTavish343: so plzz Sorry for this

Answers

Answered by MacTavish343
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); 
    }
}







MacTavish343: bro I'm in class so.....
MacTavish343: i didn't see your question carefully
aryan014: its ok
aryan014: bt thnx
aryan014: by the way yr u r awesome
aryan014: u helped so many children
MacTavish343: thanks
MacTavish343: bro
kvnmurty: Can you write with scanner class? Can you give some code in the comments
MacTavish343: yesss
Similar questions