for this java code import java.util.*;

import javax.swing.JOptionPane;

public class Maze {
    private final int rows;
    private final int cols;
    private final int[][] maze;
    private final int startRow;
    private final int startCol;
    private final int endRow;
    private final int endCol;
    private final Random random;

    public Maze(int rows, int cols) {
        this.rows = rows;
        this.cols = cols;
        this.maze = new int[rows][cols];
        this.startRow = 0;
        this.startCol = 0;
        this.endRow = rows - 1;
        this.endCol = cols - 1;
        this.random = new Random();
        generateMaze();
    }

    private void generateMaze() {
        // Initialize maze with blocked cells
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                maze[i][j] = -1; // blocked cell
            }
        }
        
        // Generate paths using recursive backtracking algorithm
        Stack<int[]> stack = new Stack<>();
        int[] current = {0, 0};
        maze[0][0] = 0; // start cell
        stack.push(current);
        while (!stack.isEmpty()) {
            current =stack.pop();
            int row = current[0];
            int col = current[1];
            List<int[]> neighbors = getUnvisitedNeighbors(row, col);
            if (!neighbors.isEmpty()) {
                stack.push(current);
                int[] next = neighbors.get(random.nextInt(neighbors.size()));
                int nextRow = next[0];
                int nextCol = next[1];
                maze[nextRow][nextCol] = 0; // path cell
                stack.push(next);
            }
        }
        
        // Add coins and traps randomly
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                if (maze[i][j] == 0) { // path cell
                    if (random.nextDouble() < 0.2) { // 20% chance of adding a coin
                        maze[i][j] = 1; // coin cell
                    } else if (random.nextDouble() < 0.1) { // 10% chance of adding a trap
                        maze[i][j] = -2; // trap cell
                    }
                    else if (random.nextDouble() < 0.05) {
                    	
                    	 maze[i][j] = -1;
                    }
                }
            }
        }
    }

    private List<int[]> getUnvisitedNeighbors(int row, int col) {
        List<int[]> neighbors = new ArrayList<>();
        if (row > 0 && maze[row-1][col] == -1) { // top neighbor
            neighbors.add(new int[]{row-1, col});
        }
        if (row < rows-1 && maze[row+1][col] == -1) { // bottom neighbor
            neighbors.add(new int[]{row+1, col});
        }
        if (col > 0 && maze[row][col-1] == -1) { // left neighbor
            neighbors.add(new int[]{row, col-1});
        }
        if (col < cols-1 && maze[row][col+1] == -1) { // right neighbor
            neighbors.add(new int[]{row, col+1});
        }
        return neighbors;
    }

    public int[][] getMaze() {
        return maze;
    }

    public int getStartRow() {
        return startRow;
    }

    public int getStartCol() {
        return startCol;
    }

    public int getEndRow() {
        return endRow;
    }

    public int getEndCol() {
        return endCol;
    }
   


    public static void main(String[] args) {
    	String input1 = JOptionPane.showInputDialog(null, "Enter the first integer:");
        int x = Integer.parseInt(input1);

        // Input the second integer
        String input2 = JOptionPane.showInputDialog(null, "Enter the second integer:");
        int y = Integer.parseInt(input2);
    	
    	
    	
        Maze Maze = new Maze(x, y); // generate a 10x10 maze
        int[][] maze = Maze.getMaze(); // get the generated maze
        int startRow = Maze.getStartRow(); // get the start row of the maze
        int startCol = Maze.getStartCol(); // get the start column of the maze
        int endRow = Maze.getEndRow(); // get the end row of the maze
        int endCol = Maze.getEndCol(); // get the end column of the maze
        
        // Iterate over the maze and print the value of each cell
        for (int i = 0; i < maze.length; i++) {
            for (int j = 0; j < maze[0].length; j++) {
                int cell = maze[i][j];
                if (cell == -1) {
                    System.out.print("#"); // blocked cell
                } else if (cell == 0) {
                    System.out.print("."); // path cell
                } else if (cell == 1) {
                    System.out.print("$"); // coin cell
                } else if (cell == -2) {
                    System.out.print("*"); // trap cell
                }
            }
            System.out.println();
        }
        
        // Print the start and end positions
        System.out.println("Start: (" + startRow + ", " + startCol + ")");
        System.out.println("End: (" + endRow + ", " + endCol + ")");
    
}}