Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I need help with my Java assignment. Please let me know if you need additional information, thank you in advance. Write a program that

Hello, I need help with my Java assignment. Please let me know if you need additional information, thank you in advance.

image 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 (arrayA, 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]=arrayA[O]+arrayB[O]). 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 double[] 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 array A 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 42.5 5.3 1.0 2.73 2.5 6.7 8.1 255.3 1.0 2.7 25 6.7 8.1 5.0 12.0 9.127 3 4.7 10 21.24 34.5 44.220 5.0 4.7 10.0 21.2 34.5 44.220 5.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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions