/*********************************************************
 * Build a multiplication table
 * Instance Service Class 
 ********************************************************/

public class Multply
{    
    int maxRow;                                         //create instance fields
    int maxCol;

    //--- Constructor ------------------------------------------------------

    Multply(int row, int col)                           //takes row and column values
    {
        maxRow = row;                                   //initialize fields
        maxCol = col;    
    }

    //--- getRandom (static) method ---------------------------------------------

    static int getRandom(int min, int max)              //get min value & max value
    {
        int rand;                                       //create a local variable
        rand = (int) (Math.random() * (max-min+1));     //random dist over max-min
        rand = rand + min;                              //add the minimum value
        return (rand);                                  //return the random number
    }

    //--- mult table (instance) method -------------------------------------------

    void table()
    {   
        int row, col, colHead, result;
    
        for (colHead = 1; colHead <= maxCol; colHead++)     //create loop for col headers
            System.out.print("\t<" + colHead + ">");                                                        
       
        System.out.println();                               //print a new line
 
        for (row = 1; row <= maxRow; row++)                 //create a for loop for rows
        {
            System.out.print("<" + row + ">\t");            //print the row header
            
            col = 1;            
            while (col <= maxCol)                           //create a while loop for columns
            {
                result = row * col;
                System.out.print(" " + result + "\t");
                col++;
            }                                               
            System.out.println();                           //print a new line
        }
    }
}