Using two dimensional array, create a program that will display multiplication table but the size would be depends on the entered number of rows and columns.
Sample INPUT:
Enter numbers of ROWS: 3
Enter numbers of COLUMNS: 4
OUTPUT:
My Own Multiplication Table
***********************************************
1 2 3 4
2 4 6 8
3 6 9 12
***********************************************
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Enter row: ");
int x = in.nextInt();
System.out.print("Enter column: ");
int y = in.nextInt();
int[][] arr = new int[x][y];
System.out.println("********************************************");
for(int i = 1; i <= x; i++){
for(int j = 1; j <= y; j++){
System.out.print((i*j) + " ");
}
System.out.println("");
}
System.out.println("********************************************");
}
}
Comments
Leave a comment