Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function called combineArray that takes three arrays (a, b,and c) of int

ID: 3614883 • Letter: W

Question

Write a function called combineArray that takes three arrays (a, b,and c) of int values as its arguments (parameters). Thefunction goes through the first two arrays element by element, addsup the values in a[i] and b[i], and stores the results in c[i]. The function's return value will be boolean, and it willreturn false if any of the three arrays have different lengths;otherwise, it returns true.

I wrote the function and it compiles but the output is gibberish(Ex. [I@388c74)
Not understanding what is happening.
Here is the code I have:

public class combineArrays{
//public static void main(String [] args){
   public static int [] combineArrays(int [] a, int []b){
   int[] listSum = new int[6];
   for (int i = 0; i < 6; i++)
        listSum[i] = a[i] +b[i];
   return listSum;
   }
   
    public static void main(String [] args){
    int[] lista = { 3, -1, 0, 3, 5, 9};
    int[] listb = { 4, 2, 0, 1, 2, -3 };
   // int[] listSum = new int [6];
    for (int i = 0; i < 6; i++){
    System.out.println(combineArrays(lista,listb));
}
    }
}


Explanation / Answer

please rate - thanks you didn't say what happens with the extra elements if the arraysare different sizes, so I ignored them import java.util.*; public class untitled { public static void main(String[]args) { int[] lista = { 3, -1, 0, 3, 5, 9};     int[] listb = { 4, 2, 0, 1, 2, -3 };    int[] listSum = new int [6];    boolean good;    good=combineArrays(lista, listb,listSum);    System.out.println(good);     for (int i = 0; i < 6; i++)     System.out.println(listSum[i]);                 }//end of main public static boolean combineArrays(int lista[],int listb[],intlistc[]) {boolean same=true; int len,len2,i; len=lista.length; if(lista.length!=listb.length)       {same=false;        if(len>listb.length)              {len=listb.length;              }        } for(i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote