
-----------------------------------
Gerkin
Tue May 31, 2005 9:07 pm

My matrix program
-----------------------------------

import java.lang.*;

public class matrixmaker2

{
    public static void main (String args[])

    {
        int dimensioncoulmns;
        int dimensionrows;
        int mymatrix[] [];
        //int width[][];
        System.out.println ("Welcome to Matrix maker!");
        System.out.println ("------------------------");
        System.out.println ("Enter the dimensions of the matrix:");
        System.out.println ("Please first enter in the number of rows u wish to have in the matrix:");
        dimensionrows = TextIO.getInt ();
        System.out.println ("Now please enter in the length of the number of coulmns u wish to have:");
        dimensioncoulmns = TextIO.getInt ();

        System.out.println ("Dimensions are: " + dimensionrows + " rows " + "by " + dimensioncoulmns + " coulmns.");
        //height =  new int [dimensionheight];
        //width = new int [dimensionwidth];
        mymatrix = new int [dimensioncoulmns] [dimensionrows];
        for (int i = 0 ; i < dimensioncoulmns ; i++)
        {
            for (int j = 0 ; j < dimensionrows ; j++)
            {

                System.out.println ("Plz enter in the number u wish to have in position row " + (i+1) + " coulmn " + (j+1));
                mymatrix [i] [j] = TextIO.getInt ();

            }
        }
        System.out.println ("");
        System.out.println ("");
        System.out.println ("");
        System.out.println ("Here is your matrix with the dimensions of " + dimensionrows + " by " + dimensioncoulmns);
        System.out.println ("");
        System.out.println ("");
        
        for (int i = 0 ; i < dimensioncoulmns ; i++)
        {
            System.out.print ("( ");
        
            for (int j = 0 ; j < dimensionrows ; j++)
            {

                System.out.print (mymatrix [i] [j] + " ");

            }
            System.out.print (")");
            
            System.out.print ("\n");
        }
    }
}




As you can see, the program creates matrices. What I want to do is make this program able to multiply and add another matrix with GUI. What I need to know is how to open a matrix with rows and columns corresponding to the number of textboxes in the new window.

-----------------------------------
wtd
Tue May 31, 2005 11:01 pm


-----------------------------------
My suggestion is to create a Matrix class, so you can easily have multiple matrix objects.

class Matrix
{
   private int rows, cols;
   private T

-----------------------------------
McKenzie
Wed Jun 01, 2005 1:53 am


-----------------------------------
With anyone else most readers would know that kava is just a typo, but because you know so many languages many readers will assume this is some sort of Java offshoot language. The only problem with your code is that because Generics were only introduced in JDK 5.0 the vast majority of the students won't be able to use this at school.

-----------------------------------
wtd
Wed Jun 01, 2005 2:06 am


-----------------------------------
Thanks for spotting that.  I guess there are times when my own level of knowledge comes back to bite me.  :)
