JAVA ARRAY MANIPULATION QUESTION: make a method called manipulator that takes a double array as parameter and modifies it. The method will modify the array then print the array. The method must modify the existing array, it CAN NOT create a different array as the solution. The manipulator method will be a void method.   Remember: To get an average of 2 digits you add them together then divide by 2. Average of x and y = (x+y)/2   Modifications the method will do: For every 2 consecutive elements in the array, both the elements are replaced by their average.  If the number of elements in an array is odd don't modify the last number of the array.   Basically, you find the average of 2 consecutive elements then replace both of the elements with that value. Examples: Array = {2.0,3.0} will be changed to {2.5,2.5} when passed to the manipulator method Array = {2.0,3.0,45} will be changed to {2.5,2.5,45} when passed to the manipulator method Array = {2.0,3.0,45,55} will be changed to {2.5,2.5,50,50} when passed to the manipulator method Array = {2.0,3.0,45,55,9} will be changed to {2.5,2.5,50,50,9} when passed to the manipulator method Remember if the amount of elements in the array is odd don't modify the last element.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

JAVA ARRAY MANIPULATION QUESTION:

make a method called manipulator that takes a double array as parameter and modifies it. The method will modify the array then print the array. The method must modify the existing array, it CAN NOT create a different array as the solution. The manipulator method will be a void method.

 

Remember: To get an average of 2 digits you add them together then divide by 2. Average of x and y = (x+y)/2

 

Modifications the method will do:

For every 2 consecutive elements in the array, both the elements are replaced by their average. 

If the number of elements in an array is odd don't modify the last number of the array.

 

Basically, you find the average of 2 consecutive elements then replace both of the elements with that value.

Examples:

Array = {2.0,3.0} will be changed to {2.5,2.5} when passed to the manipulator method

Array = {2.0,3.0,45} will be changed to {2.5,2.5,45} when passed to the manipulator method

Array = {2.0,3.0,45,55} will be changed to {2.5,2.5,50,50} when passed to the manipulator method

Array = {2.0,3.0,45,55,9} will be changed to {2.5,2.5,50,50,9} when passed to the manipulator method

Remember if the amount of elements in the array is odd don't modify the last element.

 

 

Thanks in advance for help.

 

 

 

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage