Question: Submission: Submit a java file named lastName_firstName_Lab_6_1 java 1. Write a method rotateArray that is passed an array, x, of integers (minimum 7 numbers) and
Submission: Submit a java file named lastName_firstName_Lab_6_1 java 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: 1 2 3 4 5 6 7 and the value ofn = 3 Your program should first calculate the sum of numbers at even indexes (consider 0 as even) which in 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 After 1st rotation the array contents are 2345671 After 2nd rotation the array contents are. 3 4 5 6 7 1 2 After 3rd rotation the array contents are-4567123 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
Get step-by-step solutions from verified subject matter experts
