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

PLZ can u help me to solve this Q. by using java (netbeans) solve using Two-Dime

ID: 3796068 • Letter: P

Question

PLZ can u help me to solve this Q.

by using java (netbeans)

solve using Two-Dimensional Arrays :

In chess, the knight moves in a very special way:      

either:       two squares forward and one to the side

or :       one square forward and two to the side

Write a program to print the Probability of the moves

and the main for the programm

here

here

here

here

Knight

here

here

here

here

//Assuming that knights initial position is given as (x,y) and n is the number of moves remaining

double findProb(int x, int y, int n){

   double[][] mat = new double[8][8];

   for(double[] row: mat)

       Arrays.fill(row, -1.0);

   findProbUtil(mat, x, y, n);

}

double findProbUtil(double[][8] m, int x, int y, int n){

   if(x<0 || x>7 || y<0 || y>7)

       return 0;

   if(n==0)

       return 1;

   if(m[x][y]!=-1)

       return m[x][y];

   double res = 0.0;

   //for all possible next moves

   res += findProbUtil(m, x+2, y+1, n-1);

   res += findProbUtil(m, x+1, y+2, n-1);

   res += findProbUtil(m, x-1, y+2, n-1);

   res += findProbUtil(m, x-2, y+1, n-1);

   res += findProbUtil(m, x-2, y-1, n-1);

   res += findProbUtil(m, x-1, y-2, n-1);

   res += findProbUtil(m, x+1, y-2, n-1);

   res += findProbUtil(m, x+2, y-1, n-1);

   m[x][y] = res;

   return res;

}

this the code but without the main can u help me to do the main for this code to run the program plz

here

here

here

here

Knight

here

here

here

here

Explanation / Answer

//Assuming initial values to be enter by the user

Class ChessKnight{

public static void main(Static String Args[]){

System.out.println("Please enter the intial postion of knight in form of 2d array:");

Scanner read = new Scanne(System.in);

int x= read.nextInt();

int y= read.nextInt();

System.out.println("Please enter number of moves remaining:");

int n= read.nextInt();

System.out.println("Required probablity is " + findProb(x,y,n));

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote