Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions