Question: Can you give me the full code for the following java program, I already did some of the code but for replaceCells, I am not

Can you give me the full code for the following java program, I already did some of the code but for replaceCells, I am not able to get the correct output for two of my tests:
Objectives
To practice writing recursive methods.
Overview
For this assignment you will implement a set of recursive methods processing strings and arrays. One of methods (replaceCells) illustrates the power of recursion. Think how would you implement this method without recursion. These are all of the methods that need to be implemented in the program(do not add a main() to the program):
Grading
(100%) Release Tests
Code Distribution
A package named sysImplementation - In this package you will find the Utilities.java class. You need to provide an implementation for each of the methods in this class. Information about each method can be found at javadoc
Links to an external site.
.
A package named tests - Includes a shell file for your student tests.
Specifications
Your methods must be recursive.
You may not use any kind of loop construct (e.g., for, while, do while).
You may not add any instance/static variables to the Utilities class.
Your release test points could be adjusted if you do not follow the above specifications.
You may not use Arrays class methods (except for your student tests).
You may not use the ArrayList class except for the getListRowIndices method.
You may use loops for your student tests.
All your auxiliary methods should be defined as private.
Do all your testing in your StudentTests.java file and do not add a main() to Utilities.java.
Do not add any additional classes
Make sure that you are calling your methods using x and y correctly (and not switching them by mistake
This is the driver: package sysImplementation;
import java.util.Arrays;
import java.util.ArrayList;
public class SampleDriver {
public static void main(String[] args){
String answer ="";
String str = "spring";
char delimeter ='*';
answer += str +"--->"+ Utilities.addDelimiter(str, delimeter)+"
";
str ="c2o3l4le6ge";
answer += str +"--->"+ Utilities.getDigits(str)+"
";
char[] array ={'r','a','c','e','c','a','r'};
char target ='r', replacement ='*';
answer += "Original: "+ Arrays.toString(array);
answer +=", Replacing: "+ target +" with "+ replacement;
Utilities.replaceCharacter(array, target, replacement);
answer +=", Result: "+ Arrays.toString(array)+"
";
int[] intArray ={1,5,2,3,10};
answer += "Original: "+ Arrays.toString(intArray);
answer +=", Sums of Even: "+ Utilities.getSumEven(intArray);
int[][] twoDimArray ={{4,5},{1,2,3,4,5,6,7,10,11,14},{2,4,6,8},
{10,21,31,45,51,62,71,12,13,14}};
int rowLength =10;
ArrayList list = Utilities.getListRowIndices(twoDimArray, rowLength);
answer +="
Indices: "+ list.toString();
char[][] charArray ={
{'R','Y','R','Y','Y'},
{'R','Y','R','Y','Y'},
{'R','M','R','Y','Y'},
{'R','Y','Y','Y','Y'},
{'R','Y','R','Y','Y'},
{'R','Y','R','Y','P'},
};
answer +="
Original Array:
"+ printArray(charArray);
int x =1, y =3;
target ='Y';
replacement ='*';
Utilities.replaceCells(charArray, x, y, target, replacement);
answer += "After processing: "+ x+","+ y +"
"+ printArray(charArray);
answer += "END";
System.out.println(answer);
}
private static String printArray(char [][]array){
StringBuffer answer = new StringBuffer();
/* Notice how we can loop through the array */
for (char[] row : array){
for (char entry : row){
answer.append(entry +"");
}
answer.append("
");
}
return answer.toString();
}
}
The code I have for replaceCells: public static int replaceCells(char[][] arr, int a, int b, char local, char tag){
if (arr == null || a <0|| a >= arr.length || b <0|| b >= arr[a].length || arr[a][b]!= local){
return 0;
}
arr[a][b]=tag;
return 1;
+ replaceCells(arr, a +1, b, local, tag)
+ replaceCells(arr, a -1, b, local, tag)
+ replaceCells(arr, a, b +1, local, tag)
+ replaceCells(arr, a, b -1, target, tag);
}
}
The rejections Im getting are for the replaceCell method: expected: but output was: but output was:<...MRXXXRTXXXRXXRX.RRMR[...RT...R..R.Count:10]>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!