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 programdo not add a main to the program:
Grading
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 eg for, while, do while
You may not add any instancestatic 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 mainString args
String answer ;
String str "spring";
char delimeter ;
answer str Utilities.addDelimiterstr delimeter
;
str college;
answer str Utilities.getDigitsstr
;
char array racecar;
char target r replacement ;
answer "Original: Arrays.toStringarray;
answer Replacing: target with replacement;
Utilities.replaceCharacterarray target, replacement;
answer Result: Arrays.toStringarray
;
int intArray ;
answer "Original: Arrays.toStringintArray;
answer Sums of Even: Utilities.getSumEvenintArray;
int twoDimArray
;
int rowLength ;
ArrayList list Utilities.getListRowIndicestwoDimArray rowLength;
answer
Indices: list.toString;
char charArray
RYRYY
RYRYY
RMRYY
RYYYY
RYRYY
RYRYP
;
answer
Original Array:
printArraycharArray;
int x y ;
target Y;
replacement ;
Utilities.replaceCellscharArray x y target, replacement;
answer "After processing: x y
printArraycharArray;
answer "END";
System.out.printlnanswer;
private static String printArraychar array
StringBuffer answer new StringBuffer;
Notice how we can loop through the array
for char row : array
for char entry : row
answer.appendentry ;
answer.append
;
return answer.toString;
The code I have for replaceCells: public static int replaceCellschar arr, int a int b char local, char tag
if arr null a a arr.length b b arralength arrab local
return ;
arrabtag;
return ;
replaceCellsarr a b local, tag
replaceCellsarr a b local, tag
replaceCellsarr a b local, tag
replaceCellsarr a b target, tag;
The rejections Im getting are for the replaceCell method: expected: but output was: but output was:MRXXXRTXXXRXXRXRRMRRTRRCount:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
