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

Multiplication table!

$
0
0
Hi there, ok so I have two arrays already delcared & initalized and with those two array I need to multiply each to get an output of a multiplication table. Which is not working for me. thanks for the help in advanced! this is what i have 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]; //declaring even array
     even[0]=2; //starting with number 2
     System.out.println("Even Array");  //just wanted to output the array numbers for accuracy

       for(int j=0;j<6;j++) //filling the even array with even numbers from 1 to 12
        {
          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]; //declaring odd array

    odd[0] = 1; //starting with first odd number
    
    System.out.println("Odd Array"); //again just outprinting the array for accuracy

    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 + " ");
    
    
    
    System.out.println("Multiplication Table"); //just saying what this next process is

     int[][] total =new int[6][6];

     for (int i=0;i<6;i++)
     {
       for(int j=0;j<6;j++)
       
         total [i][j]= odd[i] * even[i];
     }
    for(int i=0;i<6;i++)
    System.out.println(total);
    
    

  }
}
  




and right now it is compiling perfectly but the interactions pane shows this:


[[I@36be4fd5
[[I@36be4fd5
[[I@36be4fd5
[[I@36be4fd5
[[I@36be4fd5
[[I@36be4fd5

Viewing all articles
Browse latest Browse all 51036

Trending Articles



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