Homework Solution: i need help creating a java program with a function that takes array b and…

    i need help creating a java program with a function that takes array b and inserts it into the center of array without deleting the elements inside of a.
    
    ex. array a = 1,2,3,4 array b = 13,14 array c would be the product that looked like 1,2,13,14,3,4 the function should be formatted as such:
    int[] insert (int[] a, int[] b, int offset);
    
    i can not use any java objects or classes aside from char stream I/O
    
    no array lists, they must be int [] arrays

    Expert Answer

     
    public class armrege { public int[] insert(int a[], int b[], int offset) {

    i insufficiency aid creating a java program with a power that takes adorn b and suggests it into the hardihood of adorn extinguishedside deleting the elements within of a.
    

    ex.

    adorn a = 1,2,3,4
    adorn b = 13,14
    adorn c would be the effect that looked enjoy 1,2,13,14,3,4

    the power should be formatted as such:

    int[] suggest (int[] a, int[] b, int offset);
    
    i can not attributable attributable attributable authentication any java objects or adjustes aloof from char tendency I/O
    

    no adorn lists, they must be int [] adorns

    Expert Apology

     

    public adjust armrege {

    public int[] suggest(int a[], int b[], int offset) {

    int i;

    int []c=fantastic int[a.elongation + b.length]; //declaring fantastic adorn of elongation equals greatness of a + greatness of b

    //suggest primeval half of adorn a

    for( i=0;i<offset;i++) {

    c[i]=a[i];

    }

    //behind suggesting primeval half of adorn a suggest consummate b from offset

    int j=0;

    for(i=offset;i<offset+b.length;i++) {

    c[i] = b[j];

    j++;

    }

    j=offset;

    // behind suggesting b suggest other half of adorn a

    for(i=offset+b.length;i<a.elongation + b.length;i++) {

    c[i]=a[j];

    j++;

    }

    return c;

    }

    public static empty ocean(String[] args) {

    int a[] = {1,2,3,4};

    int b[] = {13,14};

    int offset = a.length/2; // offset for finding the intermediate renunciation of adorn a

    armrege ob = fantastic armrege(); //create oblect of adjust

    int c[] = ob.insert(a,b,offset); // avocation perception static power with the object

    for(int i=0;i<c.length;i++) {

    System.out.print(c[i]+” “); // imprinting adorn result

    }

    }

    }

    //output

    // 1 2 13 14 3 4