Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/10/2009, 12:23
Gaug
 
Fecha de Ingreso: junio-2009
Mensajes: 250
Antigüedad: 14 años, 11 meses
Puntos: 1
Problema con Calculadora.

Hola.

Tengo una calculadora de matrices en Java, pero me fallan algunas cosas bàsicas al declarar mètodos, me gustarìa que le dieran un vistazo al programa y me dijeran que hay que corregir, ya que en sì la estructura del programa ya está hecha, gracias de antemano.

Código Java:
Ver original
  1. import java.io.*;
  2. class Leer   /// CLASE PARA LEER VALORES!!
  3. {
  4.     static String dato ()
  5.     {
  6.         String sdato= "";
  7.         try
  8.         {
  9.             InputStreamReader isr = new InputStreamReader (System.in);
  10.             BufferedReader flujoE = new BufferedReader (isr);
  11.  
  12.             sdato = flujoE.readLine ();
  13.         }
  14.         catch (IOException e)
  15.         {
  16.             System.err.println ("Error: " + e.getMessage ());
  17.         }
  18.         return sdato;
  19.     }
  20.     public static int datoInt ()
  21.     {
  22.         try
  23.         {
  24.          return Integer.parseInt (dato());
  25.         }
  26. {
  27.     return Integer.MIN_VALUE;
  28. }
  29. }
  30.  
  31. public static float datoFloat ()
  32. {
  33.     try
  34.     {
  35.         return Float.parseFloat (dato());
  36.     }
  37.     catch (NumberFormatException e)
  38.     {
  39.         return Float.MIN_VALUE;
  40.     }
  41. }
  42. }   /// TERMINA CLASS LEER
  43.  
  44.  class Matris {
  45.  
  46.      int arreglo[][];
  47.  
  48.     public void Matris(int x)
  49.     {
  50.     arreglo = new int[x][x];
  51.  
  52.     }
  53.  
  54. }
  55.  
  56.  
  57. public class Matriz
  58. {
  59.    
  60.     static Matris result = new Matris (3);
  61.     static Matris a = new Matris(3);
  62.     static Matris b = new Matris (3);
  63.  
  64.     public  Matris Suma(Matris a,Matris b) {
  65.         for (int i = 0; i <4 ; i++) {
  66.             for (int j = 0; j <4 ; j++) {
  67.                 result.arreglo[i][j] = a.arreglo[i][j] + b.arreglo[i][j];
  68.             }
  69.         }
  70.         return result;
  71.     }
  72.  
  73.     public Matris  resta(Matris a, Matris b) {
  74.         for (int i = 0; i < 4; i++) {
  75.             for (int j = 0; j < 4; j++) {
  76.                 result.arreglo[i][j] = a.arreglo[i][j] - b.arreglo[i][j];
  77.             }
  78.         }
  79.         return result;
  80.     }
  81.  
  82.     public Matris multiplicacion(Matris a, Matris b) {
  83.         for (int i = 0; i < 4; i++) {
  84.             for (int j = 0; j < 4; j++) {
  85.                 result.arreglo[i][j] = a.arreglo[i][j] * b.arreglo[j][i];
  86.             }
  87.         }
  88.         return result;
  89.     }
  90.     public Matris traspuesta(Matris a, Matris b) {
  91.         for (int i = 0; i < 4; i++) {
  92.             for (int j = 0; j < 4; j++) {
  93.                 result.arreglo[i][j] = a.arreglo[j][i];
  94.             }
  95.         }
  96.         return result;
  97.     }
  98.     public static void pedir_valores()
  99.     {
  100.         for(int i=0;i<3;i++)
  101.                     {
  102.                         for(int j=0; j<3;j++)
  103.                         {
  104.                             System.out.println("Inserte el valor de la Matriz A en la posición ["+i+"] ["+j+"]");
  105.                             a.arreglo[i][j] = Leer.datoInt();
  106.                         }
  107.                     }
  108.                     for(int i=0;i<3;i++)
  109.                     {
  110.                         for(int j=0; j<3;j++)
  111.                         {
  112.                             System.out.println("Inserte el valor de la Matriz B en la posición ["+i+"] ["+j+"]");
  113.                             b.arreglo[i][j] = Leer.datoInt();
  114.                         }
  115.                     }
  116.     }
  117.    
  118.     public static void main (String args[])
  119.     {
  120.         int opc;
  121.             System.out.println("*******************************************\n"+
  122.                            "*    ¿ Qué operación deseas hacer ?       *\n"+
  123.                            "*                                         *\n"+
  124.                            "*   1. Suma de matrices                   *\n"+
  125.                            "*   2. Resta de matrices                  *\n"+
  126.                            "*   3. Multiplicación de matrices         *\n"+
  127.                            "*   4. Transpuesta de una matriz          *\n"+
  128.                            "*                                         *\n"+
  129.                            "*******************************************");
  130.             opc = Leer.datoInt();
  131.             switch(opc)
  132.             {
  133.                 case 1:
  134.                     pedir_valores();
  135.                    
  136.             }
  137.            
  138.  
  139.            
  140.     }
  141.  
  142. }

Saludos y de nuevo gracias.