Question
I need help with this, below is a close-up of what the output should look like Here's the copy-pastable code: public class CharArrayProject_3_Driver { public
I need help with this, below is a close-up of what the output should look like
Here's the copy-pastable code:
public class CharArrayProject_3_Driver { public static void main( String args[] ) { char a[] = { 'h','o','l','l','y', 'c','l','e','m','e','n','c','e' }; CharArrayProject_3 hello = new CharArrayProject_3( a ); System.out.print( hello ); hello.deleteRepeats(); System.out.println(); System.out.print( hello ); System.out.print( " ----------------------------- " + "----------------------------- "); char b[] = { 'a','b','c','b','b', 'c','a','d','a','d','c' }; hello = new CharArrayProject_3( b ); System.out.print( hello ); hello.deleteRepeats(); System.out.println(); System.out.print( hello ); } } public class CharArrayProject_3 { private char[] array; public CharArrayProject_3( char[] arr ) { array = new char[ arr.length ]; numberOfRepeats = 0; for( int k = 0; k 3. Complete the class CharArrayProject_3 to produce the output shown. Basically, class CharArray Project_3 removes repeating elements from an array of chars. Notice that every time a match is found the elements in the array are shifted down thereby affecting the position of the subsequent elements public class CharArrayProject_3_Driver public static void main( String args[]) char a[] = { "h", '','1','1', 'y", C l .lel. .in. c . e CharArrayProject 3 hello - new CharArrayProject_3( a ): System.out.print( hello ): hello deleteRepeats: System.out.println(); System.out.print( hello ): System.out.print(" - char b[] = {'a','b', 'c','b','b'. c', 'a', 'd', 'a','d', 'c' }; hello - new CharArrayProject_3( b ); System.out.print( hello ) hello.deleteRepeats : System.out.println System.out.print( hello ): Blue Terminal Window - Chapter 6 x Options public class CharArrayProject_3 private chart) array: 1,0,1,1.7.c.1.e.n.e..c.e target - O MATCE! target - - MATCH! target BERY13] -1 - MATCH! IS - MATCH! - 10 MATOR! --> --> ARRAY SHIFTED! ARRAY SKITTED! public CharArrayProject_3( char[] arr) YATOR ARRAY SHIFTED! array - new chart arr. length : numberOfRepeats - 0: for(int k = 0; k arr.length; k++) {array[k] - arr[k]; } [9] - targete 11 -. - MATOR! -> > ARRAY SHIFTED! ARRAY SRITTED! Largot - target - - -> NO MATOR! NO MATCE! public void deleteRepeats) 8.b,c,,,,,,,, WERY HITTED public String toString() String result - SENY) - erry [5] - - MATCE! target=d BEER 4] - - MICE! nber of repeats = 7 - ARRAY SEIFTED! return result: Bluel: Terminal Window - Chapter 6 Options ==> ARRAY SHIFTED! ==> ARRAY SHIFTED! h,0,1,1,y,c,l,e,m, e, n,c,e target = h --> NO MATCH! target = ==> NO MATCH! target = 1 array[3] = 1 ==> MAICH! array(5] -1 ==> MATCH! target - y ==> NO MATCH! target=C array[9] = C ==> MATCH! target = e array[7] = e ==> MATCH! array[8] = e ==> MATCH! target = m ==> NO MATCH! target - n ==> NO MATCH! number of repeats = 5 h,0,1,Y, c, e, men ==> ARRAY SHIFTED! ==> ARRAY SHIFTED! ARRAY SHIFTED! ==> ==> ARRAY SHIFTED! ARRAY SHIFTED! ==> ARRAY SHIFTED! ==> ARRAY SHIFTED! a, b, c, b, b,c,a,d,a,d,c target - a array[6] = a ==> MATCH! array[7] =a ==> MATCH! target - b array[3] = b MATCH! array[3] = b ==> MATCH! target=C array[3] = C ==> MATCH: array(5] = c ==> MATCH! target = d array[4] = d ==> MATCH! number of repeats = 7 a,b,c,d ==> ARRAY SHIFTED! ==> ARRAY SHIFTED! ==> ARRAY SHIFTED
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started