Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

here is my code with the empty findpath Method import java.io.*; import java.uti

ID: 3542493 • Letter: H

Question

                


                

                    here is my code with the empty findpath Method
                

                

                    
                

                                     import java.io.*;
                    import java.util.Scanner;
                    
                    public class TerrainScanner
                    {
                    private double terrain[][];
                    char map[][] = new char[10][10];
                    


public char[][] findPath(int startRow, int startCol, int destRow, int destCol,
                    int threshold){
                    
                    
                    
                    
                    



                    
                    }
                    
                    /**
                    * @param in scanner to read from input file
                    * @param r row
                    * @param c column
                    * @param sum take sum of rows
                    */
                    public void scanTerrain(String terrainMap)
                    throws IOException
                    {
                    Scanner in = new Scanner(new BufferedReader(new FileReader(terrainMap)));
                    for(int r = 0; r < 10; r++)
                    {
                    for(int c = 0; c < 10; c++)
                    {
                    int sum = 0;
                    for(int i = 0; i < 6; i++)
                    sum += in.nextInt();
                    
                    in.nextLine();
                    terrain[r][c] = sum / 6.00;
                    }
                    
                    }
                    
                    }
                    
                    /**
                    * @param in scanner to read from input file
                    * @param r row
                    * @param c column
                    */
                    public char[][] generateMap(int threshold)
                    {
                    
                    for(int r = 0; r < 10; r++)
                    {
                    for(int c = 0; c < 10; c++)
                    {
                    char mark;
                    if(terrain[r][c] > (double)threshold)
                    {
                    mark = 'X';
                    } else
                    {
                    mark = ' ';
                    int i = 0;
                    if(r + 1 < 10 && checkIfPassable(r + 1, c, threshold))
                    i++;
                    if(r - 1 >= 0 && checkIfPassable(r - 1, c, threshold))
                    i++;
                    if(c + 1 < 10 && checkIfPassable(r, c + 1, threshold))
                    i++;
                    if(c - 1 >= 0 && checkIfPassable(r, c - 1, threshold))
                    i++;
                    mark = (char)(i + 48);
                    }
                    map[r][c] = mark;
                    }
                    
                    }
                    
                    return map;
                    }
                    
                    /**
                    * @return terrain at the current position within selected threshold
                    */
                    public boolean checkIfPassable(int row, int col, int threshold)
                    {
                    return terrain[row][col] <= (double)threshold;
                    }
                    /**
                    * @return highest elevations
                    */
                    public double getHighestElevation()
                    {
                    double max = terrain[0][0];
                    for(int r = 0; r<10; r++){
                    for (int c = 0; c<10; c++)
                    if(max < terrain[r][c]){
                    max = terrain[r][c];
                    }
                    }
                    return max;
                    }
                    /**
                    * @return lowest elevation
                    */
                    public double getLowestElevation()
                    {
                    double min = terrain[0][0];
                    for(int r = 0; r<10; r++){
                    for (int c = 0; c<10; c++)
                    if(min > terrain[r][c]){
                    min = terrain[r][c];
                    }
                    }
                    return min;
                    }
                    
                    /**
                    * @param terrain = 2D array to hold terrain averages
                    */
                    public TerrainScanner()
                    {
                    terrain = new double[10][10];
                    }
                    
                    
                    
                    }

You have to write a recursive method to find a path fromAto B You program should be able to display the path on the map Each cell on the path should be marked by letter "S"(South) or "N"(North) or 'E'(East) or "W"(West), which tells people the direction that they should go The destination cell should be marked by "^". Example Output

Explanation / Answer

package bessiehorseshoe;


import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;


public class BessieHorseShoe {


int answer = 0;

int matrixSize = 0;


public static void main(String[] args) throws IOException {

BessieHorseShoe goBessieGo = new BessieHorseShoe();

}


BessieHorseShoe() throws IOException {

int rowFilled = 0;

int currentColumn = 0;

int character = 0;


BufferedReader inputFile = new BufferedReader(new FileReader("hshoe.in"));

String inputLine = inputFile.readLine();

matrixSize = Character.digit(inputLine.charAt(0), 10);

System.out.println(matrixSize);


char[][] pMatrix = new char[matrixSize][matrixSize];


while ((character = inputFile.read()) != -1) {

char c = (char) character;

if (c == '(' || c == ')') {

pMatrix[rowFilled][currentColumn] = c;

System.out.print(pMatrix[rowFilled][currentColumn]);

rowFilled++;

if (rowFilled == matrixSize) {

currentColumn++;

rowFilled = 0;

System.out.println();

}

}

}

matchHorseShoes(pMatrix);

}


public int matchHorseShoes(char[][] pMatrix) {

if (pMatrix[0][0] == ')') {

System.out.println("Pattern starts with ')'. No possible path!");

return 0;

}

System.out.println("Works");

return 0;

}

}