Xtrminator

Globales

Mar 8th, 2012
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import javax.swing.JOptionPane;
  2. import java.util.Arrays;
  3.  
  4.  
  5. public class Globales
  6. {
  7.  
  8.  
  9. public static void main(String args[])
  10. {
  11. int arreglo [][] = new int [3][3];
  12. int arreglo2 [][] = new int [3][3];
  13. int arreglo3 [][] = new int [3][3];
  14. int arreglo4 [][] = new int [3][3];
  15.  
  16.  
  17. for(int r = 0; r < 3; r++)
  18. {
  19. for(int c = 0; c < 3; c++)
  20. {
  21. arreglo[r][c] = Integer.parseInt(JOptionPane.showInputDialog(null, "Ingresa el numero", JOptionPane.QUESTION_MESSAGE));
  22. }
  23. }
  24.  
  25. for(int r=0; r<3; r++)
  26.  
  27. {
  28. for(int c=0; c<3; c++)
  29. {
  30. arreglo2[r][c] = Integer.parseInt(JOptionPane.showInputDialog(null, "Ingresa datos", JOptionPane.QUESTION_MESSAGE));
  31. }
  32. }
  33.  
  34. for(int r=0; r<3; r++)
  35.  
  36. {
  37.  
  38. for(int c=0; c<3; c++)
  39.  
  40. {
  41. arreglo3[r][c] = arreglo[r][c] + arreglo2[r][c];
  42. }
  43.  
  44. }
  45.  
  46. for(int r=0; r<3; r++)
  47.  
  48. {
  49. for(int c=0; c<3; c++)
  50. {
  51. for(int k=0; k<3; k++)
  52. {
  53. arreglo4[r][c] = arreglo4[r][c] + (arreglo[r][k] * arreglo2[k][c]);
  54. }
  55. }
  56. }
  57.  
  58.  
  59. JOptionPane.showMessageDialog(null, "La suma y multiplicaion de las matrices son:","resultado", JOptionPane.PLAIN_MESSAGE);
  60. JOptionPane.showMessageDialog(null, Arrays.deepToString( arreglo, arreglo2 ) );
  61. JOptionPane.showMessageDialog(null, Arrays.deepToString( arreglo2 ) );
  62. JOptionPane.showMessageDialog(null, Arrays.deepToString( arreglo3 ) );
  63. JOptionPane.showMessageDialog(null, Arrays.deepToString( arreglo4 ) );
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment