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

Given a 2d array(row, col) determine if the element in the array is satiesfies o

ID: 3568442 • Letter: G

Question

Given a 2d array(row, col) determine if the element in the array is satiesfies or not, The element is satiesfied if the surrounding elements are similar and greater than threshold percentage. Assume the element in the array are X,O and ' '. So if an element is x at a perticular row and col, you look in the surrounding elemets if there are enough x that the element is satiesfied. If the elemet is blank it is already satiesfied. If the element is all alone on its own it is not satiesfied.

//tissue is the array that is being passed in

//row and col are also being passed in

// threshold is the percentage of like agents that must surround the agent to be satisfied

//given a tissue sample, move all of the agents that are unsatisfied

//maxRounds before the program gives up on trying to make the tissue sample satisfied

public static void moveAllUnsatisfied(char [][]tissue, int threshold)

{

}

Explanation / Answer

public static void moveAllUnsatisfied(char [][]tissue, int threshold)

{
   for(int i=0; i<5; i++)
   {
       for(int j=0; j<5:j++)
       {
           if (tissue[i][j]> thershold && tissue[i][j]==tissue[i-1][j] && tissue[i][j]==tissue           [i][j-1] && tissue[i][j]== tissue[i+1][j] && tissue[i][j+1])
           {
               System.out.println("Satisfied");
           }
           if(tissue[i][j]== ' ')
           {
               System.out.println("Satisfied");
           }

}

// code to to call the moveAllUnsatisfied() can be written in main method

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