Kelvineger

Untitled

Apr 30th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. package multimatrizes;
  8.  
  9. import javax.swing.JOptionPane;
  10.  
  11. /**
  12.  *
  13.  * @author Kelvin PC
  14.  */
  15. public class MultiMatrizes {
  16. public static void Matriz(){  
  17.     int[][] mat1 = new int[5][3];  
  18.     int[][] mat2 = new int[3][5];  
  19.     int[][] result = new int[5][5];  
  20.     int aux = 0;  
  21.      
  22.     // preenche a 1º matriz  
  23.      
  24.     for (int l = 0;l < 5;l++){  
  25.         for(int c = 0;c < 3;c++){  
  26.             mat1[l][c] = Integer.parseInt(JOptionPane.showInputDialog("Informe o valor da 1º matriz para linha "+l+" coluna "+c+" :") );  
  27.         }  
  28.     }  
  29.      
  30.     // preenche a 2º matriz  
  31.      
  32.     for (int l = 0;l < 3;l++){  
  33.         for(int c = 0;c < 5;c++){  
  34.             mat2[l][c] = Integer.parseInt(JOptionPane.showInputDialog("Informe o valor da 2º matriz  para linha "+l+" coluna "+c+" :") );  
  35.         }  
  36.     }  
  37.      
  38.      
  39.     // multiplica a matriz  
  40.      
  41.     for (int l = 0;l < 5;l++){  
  42.         for(int c = 0;c < 5;c++){  
  43.             aux = 0;  
  44.             for (int i=0; i < 3; i++ ) {  
  45.                 aux = aux + (mat1[l] * mat2[c]);  
  46.             }  
  47.             result[l][c] = aux;           // aki esta tando o erro  
  48.             System.out.print(result[l][c] + " ");  
  49.         }  
  50.     }  
  51. }
  52. }
Add Comment
Please, Sign In to add comment