Question: Implement the following method: COPYRIGHT public static String replacement(String ori, String r, String w, int N) COPYRIGHT COPY This method should replace upto the last

Implement the following method: COPYRIGHT public static String replacement(String ori, String r, String w, int N) COPYRIGHT COPY This method should replace upto the last N occurrences of the String r with String w if the total length of String w (number of occurrence of w in the resulting String X w.length() is less than 45%(inclusive) of the length of ori String; otherwise, you are going to replace upto the last N occurrences of w with r. If r or w is null or an empty String, return original String without any modification. If original String is null, return null. Otherwise, return a String after applying these rules. For example, replacement("Skiing is fun", "1", "ii",3) should return "Sking is fun" GHT COPYRIG replacement("AAABB","A","C",1) should return "AACBB" replacement("AAABB", "A","C", 2) should return "ACCBB" replacement("AAABB","A", "B",3) should return "AAAAA" Please use a comment line to record how long time you spent on this problem RIGHT
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
