Java - AYUDA MATRICES PROMEDIO Y SUMA

 
Vista:
sin imagen de perfil
Val: 10
Ha aumentado su posición en 2 puestos en Java (en relación al último mes)
Gráfica de Java

AYUDA MATRICES PROMEDIO Y SUMA

Publicado por Erick (41 intervenciones) el 06/05/2015 22:40:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.util.Scanner;
 
public class Matrices {
 
    private Scanner teclado;
    private int[][] mat;
    private int columnas;
 
    public void cargar() {
        teclado = new Scanner(System.in);
        System.out.print("Cuantas fila tiene la matriz:");
        int filas = teclado.nextInt();
        System.out.print("Cuantas columnas tiene la matriz:");
        int columnas = teclado.nextInt();
        mat = new int[filas][columnas];
        for (int f = 0; f < mat.length; f++) {
            for (int c = 0; c < mat[f].length; c++) {
                System.out.print("Ingrese componente:");
                mat[f][c] = teclado.nextInt();
            }
        }
    }
 
    public void imprimirMayor() {
        int mayor = mat[0][0];
        int filamay = 0;
        int columnamay = 0;
        for (int f = 0; f < mat.length; f++) {
            for (int c = 0; c < mat[f].length; c++) {
                if (mat[f][c] > mayor) {
                    mayor = mat[f][c];
                    filamay = f;
                    columnamay = c;
                }
            }
        }
        System.out.println("El elemento mayor es:" + mayor);
        System.out.println("Se encuentra en la fila:" + filamay + " y en la columna: " + columnamay);
    }
 
    public void imprimirMenor() {
        int menor = mat[0][0];
        int filamenor = 0;
        int columnamenor = 0;
        for (int f = 0; f > mat.length; f++) {
            for (int c = 0; c < mat[f].length; c++) {
                if (mat[f][c] > menor) {
                    menor = mat[f][c];
                    filamenor = f;
                    columnamenor = c;
                }
            }
        }
        System.out.println("El elemento menor es:" + menor);
        System.out.println("Se encuentra en la fila:" + filamenor + " y en la columna: " + columnamenor);
    }
 
    public void sumamatrices(){
 
 
 
    }
        public void Promediomatrices(){
 
    }
 
 
    public static void main(String[] ar) {
        Matrices ma = new Matrices();
        ma.cargar();
        ma.imprimirMayor();
        ma.imprimirMenor();
        ma.sumamatrices();
        ma.Promediomatrices();
    }
}


Como puedo hacer la suma de las matrices y el promedio pliss ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 10
Ha aumentado su posición en 2 puestos en Java (en relación al último mes)
Gráfica de Java

AYUDA MATRICES PROMEDIO Y SUMA

Publicado por Erick (41 intervenciones) el 07/05/2015 04:27:53
corrección:
Hacer un programa que cree una matriz de n por m luego se debe cargar con números enteros no mayores a 100 luego de que este cargada el sistema debe sacar el numero mayor digitado y otro mensaje con el numero menor y otro con la sumatoria de todos los números. y otro mensaje con el promedio del valor de los números luego un ultimo mensaje con la cantidad de números pares que hay en toda la matriz:

SOLUCIÓN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import java.util.Scanner;
 
public class Matrices {
 
    private Scanner teclado;
    private int[][] mat;
    int fil;
    int colum;
 
    public void inicio() {
        teclado = new Scanner(System.in);
        System.out.print("Cuantas fila tiene la matriz:");
        fil = teclado.nextInt();
        System.out.print("Cuantas columnas tiene la matriz:");
        colum = teclado.nextInt();
        mat = new int[fil][colum];
        for (int f = 0; f < mat.length; f++) {
            for (int c = 0; c < mat[f].length; c++) {
                System.out.print("ingrese un numero:");
                mat[f][c] = teclado.nextInt();
            }
        }
    }
 
    public void imprimir() {
        for (int f = 0; f < mat.length; f++) {
            for (int c = 0; c < mat[f].length; c++) {
                System.out.print(mat[f][c] + " ");
            }
            System.out.println();
        }
    }
 
    public void imprimirMayor() {
        int mayor = mat[0][0];
 
        for (int f = 0; f < mat.length; f++) {
            for (int c = 0; c < mat[f].length; c++) {
                if (mat[f][c] > mayor) {
                    mayor = mat[f][c];
 
                }
            }
        }
        System.out.println("El elemento mayor es:" + mayor);
 
    }
 
    public void imprimirmenor() {
        int menor = mat[0][0];
        for (int f = 0; f < fil; f++) {
            for (int c = 0; c < colum; c++) {
                if (mat[f][c] < menor) {
                    menor = mat[f][c];
                }
            }
        }
        System.out.println("El elemento menor es:" + menor);
 
    }
 
    public void suma() {
        int suma;
        int res = 0;
 
        for (int f = 0; f < fil; f++) {
            for (int c = 0; c < colum; c++) {
                suma = mat[f][c];
                res = suma + res;
 
            }
 
        }
        System.out.println("---> La suma total es: " + res);
    }
 
    public void promedios() {
        int suma;
        int res = 0;
        int divisor;
        int total = 0;
 
        for (int f = 0; f < fil; f++) {
            for (int c = 0; c < colum; c++) {
                suma = mat[f][c];
                res = suma + res;
                divisor = fil * colum;
                total = res / divisor;
            }
 
        }
        System.out.println("---> El pomedio es: " + total);
    }
 
    public void Pares() {
        int n;
        for (int f = 0; f < fil; f++) {
            for (int c = 0; c < colum; c++) {
                n = mat[f][c];
                if (n % 2 == 0) {
                    System.out.println("LOS PARES SON" + n);
                }
            }
        }
    }
 
    public static void main(String[] ar) {
        Matrices nn = new Matrices();
        nn.inicio();
        nn.imprimir();
        nn.imprimirMayor();
        nn.imprimirmenor();
        nn.promedios();
        nn.suma();
        nn.Pares();
    }
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Brian

AYUDA MATRICES PROMEDIO Y SUMA

Publicado por Brian (8 intervenciones) el 09/05/2015 02:00:50
1
2
3
4
5
6
7
8
9
10
11
12
13
public void Pares() {
	int n=0;
	for (int f = 0; f < fil; f++) {
		for (int c = 0; c < colum; c++) {
 
			if (mat[f][c] % 2 == 0) {
				n+=1;
 
			}
		}
	}
	System.out.println("LOS PARES SON :  " + n);
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar