Thursday, September 26, 2013

Exercise no. 26

package lord1;

import java.util.Arrays;

import javax.swing.JOptionPane;


public class multiplication {
  
    public static void main(String[]args)
    {
        Integer [][]etimes=new Integer[25][4];
        int time=0,loop=1;
        Integer answer=0;
        String container="Multiplication Table   \n";
        for(int x=0;x<25;x++)
        {
            for(int y=0;y<4;y++)
            {
                time+=1;
          
                if(time>10)
                {
                    time=1;
                    if(loop!=11)
                    {
                        if(loop!=10)
                        {
                            loop+=1;
                        }  
                    }
                }
                if(loop!=11)
                 {
                   etimes[x][y]=loop * time;
                   answer=etimes[x][y];
                 }
                //display in proper place
                if(time==10)
                {
                  container+=" \t   " + loop + " x " + time + " = " + answer;  
                  container+="\n";
              
                }
                else
                {
                     container+=" \t   " + loop + " x " + time + " = " + answer;  
                }
            }    //second loop
        }    //first loop
      
        JOptionPane.showMessageDialog(null,  container );  
    }
}

No comments:

Post a Comment