(java:arrays): write a program that fill 2 arrays and then finds the sum of the
ID: 3626150 • Letter: #
Question
(java:arrays): write a program that fill 2 arrays and then finds the sum of the arrays. u r to read data from a file & store the values in 2 one dimension double arrays of size 10. name of the file which contains the data for the 2 one dimension arrays isoneDimensionArrayValue.txt. your program should have generalized methods to fill,print, & sum the arrays.with generalized methods both the fill array & print array contents methods should be called more than once. sample input & output rounded to 2 decimal places: the content of the first input array is: 1.00 1.10 1.20 1.30 1.40 1.50
1.60 1.70 1.80 1.90, content of the second array is: 4.00 4.10 4.20 4.30 4.40 4.50 4.60 4.70 4.80 4.90, content of the sum array is: 5.00 5.20 5.40 5.60 5.80 6.00 6.20 6.40 6.60 6.80
Explanation / Answer
import java.util.*; import java.io.*; public class ArraySum { /** * Calculate the sum of two arrays of doubles * * @param a1 The first summand * @param a2 The second summand * @return the sum of the two argument arrays */ public static double[] sum(double [] a1, double[] a2) { // The array that will be returned double [] result = new double[a1.length]; // Populate the array that will be returned for (int i=0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.