Thursday, August 21, 2014

Multiplication Table

Program to display multiplication tables from 1 to 10 using 2d array.
___________________________________________________

import javax.swing.JOptionPane;
import javax.swing.JTextArea;

public class LabExercise26 {

    public static void main(String[] args) {
        int x[][] = new int[11][11];
           
            String all = "";
           
            for(int i = 1;i<=10;i++){
                for(int j = 1;j<=10;j++){
                    x[i][j]= i*j;
                    all = all + x[i][j] + "\t";
                }
                all = all + "\n\n";
            }
            JOptionPane.showMessageDialog(null, new JTextArea(all));    
    }
}

No comments:

Post a Comment

advertisement