Question: Task 5 ( Rotation ) Make the method public static void rotation ( char [ ] a ) . The method should rotate the

Task 5(Rotation)
Make the method public static void rotation(char[] a). The method should "rotate " the elements in a table.
A rotation is done by putting the last element first, and all other elements are shifted one step to the right.
The following example shows an application:
'H', II'}
A rotation in an empty table or table with exactly one element should not give an error message, but
the rotation will then do nothing.
Exercise 6(Rotate several places)
We continue here from the previous task, and will be able to rotate more than one step.
Create the method public static void rotation(char[] a, int k), where k is an arbitrary integer. If k=1, the
method must do the same as in the previous task.
If k>1, the method must give the same answer as if you use rotation(a)k times. If k is negative, the
rotation must go in the opposite direction. There is no limit to the size of k.
The method must be designed so that it is relatively effective. One of the tests will measure
efficiency on large tables. The following examples show areas of use:
char[]','B','C','D','E','F','G','H','I','J'}; rotation(a,3); // a is now {'H','I','J','A','B','C','D',
'E','F','G'} rotation(a,
-2); // a is now {'J','A','B','C','D','E','F','G','H','I'} rotation(a,19); // a is now {'A','B','C','D','E',
'F','G','H','I','J'}
Task 5 ( Rotation ) Make the method public static

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!