import [Link].
Scanner;
public class MatrizPromedios {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
int filas = 4;
int columnas = 3;
int[][] matriz = new int[filas][columnas];
// Ingreso de datos en la matriz
[Link]("Ingrese los números enteros en una matriz de " + filas + " x " + columnas + ":");
for (int i = 0; i < filas; i++) {
for (int j = 0; j < columnas; j++) {
[Link]("Elemento[" + i + "][" + j + "]: ");
matriz[i][j] = [Link]();
// Cálculo de promedios
double[] promediosPorFila = new double[filas];
double[] promediosPorColumna = new double[columnas];
double sumaTotal = 0;
for (int i = 0; i < filas; i++) {
int sumaFila = 0;
for (int j = 0; j < columnas; j++) {
sumaFila += matriz[i][j];
sumaTotal += matriz[i][j];
promediosPorFila[i] = (double) sumaFila / columnas;
for (int j = 0; j < columnas; j++) {
int sumaColumna = 0;
for (int i = 0; i < filas; i++) {
sumaColumna += matriz[i][j];
promediosPorColumna[j] = (double) sumaColumna / filas;
// Promedio total
double promedioTotal = sumaTotal / (filas * columnas);
// Mostrar resultados
[Link]("\nPromedios por fila:");
for (int i = 0; i < filas; i++) {
[Link]("Promedio de fila " + i + ": " + promediosPorFila[i]);
}
[Link]("\nPromedios por columna:");
for (int j = 0; j < columnas; j++) {
[Link]("Promedio de columna " + j + ": " + promediosPorColumna[j]);
[Link]("\nPromedio total de la matriz: " + promedioTotal);
[Link]();