Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Getting the Dot Product of 2 1D Arrays & putting those values in a

$
0
0
Hi there, ok so with two single array [odd array] & [even array] find the dot product of those values and set them into a 2Dimensional array. Should look like a multiplication table...this is what the code looks like so far:


import java.util.Scanner;

public class ArrayMultiplicationTable
{
  public static void main(String[]args)
  {
    Scanner test = new Scanner(System.in);
    
     int[] even = new int[6];
     even[0]=2;

       for(int j=0;j<6;j++)
        {
          for ( int i=0;i<12;i++)
           {
            if(i%2==0)
            even[j]=2 * j + even[0]; break;
           }
         }
    for (int i:even)
      System.out.println(i);

       
    int[] odd = new int[6];

    odd[0] = 1;

    for(int j = 0;j <6;j++)
    {
       for ( int i = 0;i <12;i++)
       {
         if(i%2==0)
         odd[j]= 2 * j + odd[0]; break; 
       }
    }

    for(int i: odd)
    System.out.println(i + " ");





Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>