[Solved]Java Hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh H Hhhh Hhhh H H H H H Hhhhhhh H Hh Q37260610
java
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
H HHHH HHHH H H H H
H HHHHHHH H HHH HHHH H H HH H HHHHHHHHH
H H H H H H H H H HH H
H H HHHHHHHH H H HHH HHH HHHHHH HH
E HHH GH H H H HHHHHHHHH HHHH H
HHH HHHHHHH HHHHHHHHH HHH H HHH HHHHH
H H H H H
H HHH HHHHH HHHHHHHH HH H
H H H H HH HHHHHH
HHH H HH HHH HHHHHHHHHH H HHHHHHH H H
H H H HH H H H
H H H H H H H H H H H H H H
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
Where each ‘H’ represents the hedge, the ‘E’ representthe entrance to the maze, the ‘G’ represents the goal position andthe blanks represent the paths between hedges. We will assume thatthe maze is stored in file called maze.
Write an algorithm and the corresponding code to:
1. read in the maze.
2. mark all location tried with a dot “.” and print the new maze toa file call maze.out.
3. Print message to say whether there is a path to the goal ornot.
public static void main(String[] args) throwsFileNotFoundException {
Scanner inFile = newScanner(new FileReader(“maze.txt”));
PrintWriter outFile =new PrintWriter(“outmaze.txt”);
// read the file
int col = -1;
int row = -1;
ArrayList<String>maze = new ArrayList<>();
while(inFile.hasNext()) {
maze.add(inFile.nextLine());
}
char[][] maze1 = newchar[maze.size()][maze.get(0).length()];
for (int i = 0; i <maze1.length; i++) {
for (int j = 0; j < maze1[0].length; j++) {
maze1[i][j] = maze.get(i).charAt(j);
if (maze1[i][j] == ‘E’) {
row = i;
col = j;
System.out.println(maze1[i][j]);
}
System.out.print(maze1[i][j]);
}
System.out.println();
}
}
explain every step and screenshot the output
thank you
Expert Answer
Answer to java HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH H HHHH HHHH H H H H H HHHHHHH H HHH HHH H H H HH H HHHHHHHHH H H… . . .
OR

