Question: 1. Write a method rotateArray that is passed an array, x, of integers (minimum 7 numbers) and an integer rotation count, n. x is an

 1. Write a method rotateArray that is passed an array, x,

1. Write a method rotateArray that is passed an array, x, of integers (minimum 7 numbers) and an integer rotation count, n. x is an array filled with randomly generated integers between 1 and 100 The method creates a new array with the items of x moved forward by n positions. Elements that are rotated off the array will appear at the end. Forward rotation means moving elements from right to left on paper. For example, suppose x contains the following items in sequence 1234567 and the value of n 3 Your program should first calculate the sum of numbers at even indexes (consider 0 as even) which this case is 1 +3+5+7-16, and then average of numbers at odd indexes which in this case is (2+4+6)/3 -4. After that it should make a call to rotateArray with arguments as x and n. Sample output: Output Begins The randomly generated integers in array are: 1 2 34567 Sum of numbers at even indexes 16 Average of numbers at odd indexes 4 Enter rotation count: 3 Calling rotateArray and rotating 3 times After 1st rotation the array contents are2345671 After 2nd rotation the array contents are3456712 After 3rd rotation the array contents are4567123 End of Output So after rotating by 3, the elements in the new array will appear in this sequence: 4567123

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!