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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education