Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class MatrixMul here.
- *
- * @author Dov Triestman
- */
- public class MatrixMul
- {
- int N =((int)((Math.random()*2)+2)); // 1<N<4
- int maxValue= ((int)((Math.random()*8)+2)); // 1<maxValue<10
- int[][] m1 = new int[N][N];
- int[][] m2 = new int[N][N];
- int[][] m3 = new int[N][N];
- public MatrixMul()
- {
- System.out.println("What is the N?: "+N);
- System.out.println("What is the maxValue?: "+maxValue);
- for(int i =0; i<N; i++)
- {
- for(int j=0; j<N; j++)
- {
- int random = ((int)((Math.random()*10)+1));
- m1[i][j] = random;
- m2[i][j] = random;
- boolean trueRandom = false;
- while(trueRandom == false)
- {
- random = ((int)((Math.random()*maxValue)+1));
- if(random > maxValue)
- {
- trueRandom = false;
- }
- else
- trueRandom =true;
- }
- System.out.println("Printing m1["+i+"],["+j+"]");
- System.out.println(m1[i][j]);
- System.out.println("Printing m2["+i+"],["+j+"]");
- System.out.println(m2[i][j]);
- System.out.println("Printing m3["+i+"],["+j+"]");
- for(int k=0;k<N;k++)
- {
- m3[i][j] += m1[i][k] + m2[k][j];
- System.out.println(m3[i][j]);
- }
- /*
- System.out.println("Printing m3");
- for(int k=0; k<N; k++)
- {
- m3[i][j] += m1[i][k] + m2[k][j];
- }
- */
- }
- }
- /*N = ((int)((Math.random()*4)+1));
- maxValue = ((int)((Math.random()*10)+1));
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement