Code Below:


import java.util.*;
class specialmerging
{
    public static void main()
    {
        Scanner s=new Scanner(System.in);
        int N[]=new int[6];
        int M[]=new int[4];
        int merge[]=new int[10];
        System.out.println("Enter the elements of array N");
        for (int i=0;i< 6;i++)
        {
            N[i]=s.nextInt();
        }
        System.out.println("Enter the elements of array M");
        for (int i=0;i< 4;i++)
        {
            M[i]=s.nextInt();
        }
        for (int i=0;i< 10;i++)
        {
            if(i%2==0)
            merge[i]=N[(i/2)];
            else if(i==9)
            merge[i]=N[5];
            else if(i%2==1)
            merge[i]=M[(i/2)];
        }
        System.out.println("First Array \t Second Array \t Merged Array");
        for (int i=0;i< 10;i++)
        {
            if (i< 6)
            System.out.print("\t"+N[i]+"\t");
            else
            System.out.print("\t"+" "+"\t");
            if (i< 4)
            System.out.print("\t"+M[i]+"\t");
            else
            System.out.print("\t"+" "+"\t");
            System.out.print("\t"+merge[i]);
            System.out.println();
        }
    }
}