import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    public static void main(String[] args) {

       
        int[][] libros = {
            {4, 6, 5, 7},
            {3, 2, 4, 5},
            {6, 8, 7, 9}
        };

        int total = 0;

        // Mostrar la matriz
        System.out.println("Préstamos por género y semana");
        for (int i = 0; i < libros.length; i++) {
            for (int j = 0; j < libros[i].length; j++) {
                System.out.print(libros[i][j] + "\t");
            }
            System.out.println();
        }

        System.out.println("----------------------------");

        // Calcular total por género
        for (int i = 0; i < libros.length; i++) {

            total = 0;

            for (int j = 0; j < libros[i].length; j++) {
                total += libros[i][j];
            }

            System.out.println("Total del género " + (i + 1) + ": " + total);
            System.out.println("-*-");
        }
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: