Question: REVISED - See notes at end - Needs to be Java programme Write a static method in Java called deleteRepeats that has a partially filled

REVISED - See notes at end - Needs to be Java programme

Write a static method in Java called deleteRepeats that has a partially filled array of characters as a formal parameter and that deletes all repeated letters from the array.

Because a partially filled array requires two arguments, the method should actually have two formal parameters: an array parameter and a formal parameter of type int that gives the number of array positions used. When a letter is deleted, the remaining letters are moved one position to fill in the gap. This creates empty positions at the end of the array so that less of the array is used. Because the formal parameter is a partially filled array, a second formal parameter of type int should tell how many array positions are filled. This second formal parameter cannot be changed by a Java method, so have the method return the new value for this parameter. For example, consider the following code:

char a[10];

a[0] = 'a';

a[1] = 'b';

a[2] = 'a';

a[3] = 'c';

int size = 4;

size = deleteRepeats(a, size);

After this code is executed, the value of a[0] is 'a' , the value of a[1] is 'b' , the value of a[2] is 'c' , and the value of size is 3. (The value of a[3] is no longer of any concern, because the partially filled array no longer uses this indexed variable.)

You may assume that the partially filled array contains only lowercase letters. Write a suitable test program for your method.

******Program needs to be dynamic, plz see the output exemple******

Need to take these inputs:

These character arrays are created in the program code:

Example 1 = a, b, c

Example 2 = a, b, c, c

Example 3 = a, a, b

Example 4 = b, a, a

Example 5 = c, c, c, d

Example 6 = a, b, a, c, a, a, c, d, e, e

Example 7 = a, a, b, b, b, c, d

Output Needs to be this:

REVISED - See notes at end - Needs to be Java programme

Example 1 original array values a,b, c, Revised array values after repeats removed: a, b, c, Example 2 Original array values a,b, c, c, Revised array values after repeats removed: a,b,c, Example 3 Original array values a, a,b, Revised array values after repeats removed: a,b, Example 4 original array values: b, a, a, Revised array values after repeats removed: b, a, Example 5 original array values: e, c,c, d, Revised array values after repeats removed: c,d, Example 6 original array values a,b, a, e, a, a,c, d, e,e, Revised array values after repeats r a, b, c, d, e Example 7 original array values a, a,b, b,b, c,d, Revised array values after repeats removed: a, b, c,d BUILD SUCCESSFUL (total time: 0 seconds)

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 Databases Questions!