Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that has a method called sumArrays and a method called printArray. The method sumArrays takes in two arrays of doubles (array A,

image text in transcribedimage text in transcribed

Write a program that has a method called sumArrays and a method called printArray. The method sumArrays takes in two arrays of doubles (array A, arrayB). The method then creates a new Array that has the length of the longest array that is passed in. Then add the elements of arrayA and arrayB in the same position and put the result in the new array (e.g., newArr[0]=array,[0]+arrayB[0]). If arrayA and arrayB are different lenghts, simply copy the extra elements of the longer array into the new array. Return the new array. The method header is: public static doublel] sumArrays (double [ ] arrayA, double / / arrayB] The method printArray takes in an array of doubles. It will print out the elements of the array on one line. The method header is: public static void printArray (double [] arr) You will test your method in the main method of your program by using a Scanner: Read in an int (N) representing the length of arrayA. Then read in N values into arrayA. Read in another int (N) that represents the length of arrayB. Then read in N values into arrayB. Print arrayA and arrayB by calling printArray for each one. Call the method sumArrays (passing in arrayA and arrayB). Print the returned array using printArray. Examples (note in example 1: 4 is the size of arrayA and 3 is the size of arrayB] Sample Input Sample output 4 2.5 5.3 1.0 2.73 2.5 6.7 8.1 2.5 5.3 1.0 2.7 2.5 6.7 8.1 5.0 12.0 9.1 2.7 34.7 10 21.2434.5 44.2 2.05.0 4.7 10.0 21.2 34.5 44.2 2.05.0 39.254.2 23.25.0

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

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

What Rewards Do I Value Most? (I. C. 3.)

Answered: 1 week ago

Question

a. How do you think these stereotypes developed?

Answered: 1 week ago

Question

7. Describe phases of multicultural identity development.

Answered: 1 week ago