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

package Assignment; import java.util.*; public class assignment { public static

ID: 3769771 • Letter: P

Question

package Assignment;

import java.util.*;

public class assignment
{
   public static void main(String[] args)
   {
       Scanner input = new Scanner(System.in);

       String repeat = "";

       do
       {
           byte [][] map1 = {
           {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
           {1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1},
           {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1},
           {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,0,0,1},
           {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1},
           {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1},
           {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1},
           {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
           {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};


           byte positionx = 54, positiony = 17 , finishx = 2 , finishy = 1;
           String z = "";
  
  
           String movement = "";
           String done = "";

           do
           {
               for (int i = 1 ; i <= 25 ; i++)
               System.out.println();
               for (int y = 0 ; y <= map1.length-1 ; y++)
               {
                   for (int x = 0 ; x <= map1[1].length-1 ; x++)
                   {
                       if (x == positionx && y == positiony)
                       {
                           System.out.print(z);
                       }
                       else if(y == finishy && x == finishx)
                           {
                               System.out.print("X");
                           }
                           else if (map1[y][x]==1)
                               {
                                   System.out.print("?");
                               }
                               else
                               {
                                   System.out.print(" ");
                               }
                       }
                   System.out.println();
               }
               System.out.println("W = up , A = left , S = down , D = right , E = Exit , R = Restart , N = Next");
               System.out.print("Input Movement = ");
               movement = input.nextLine();
               if (movement.equalsIgnoreCase("a"))
               {
                   positionx--;
                   if (map1[positiony][positionx]==1)
                   positionx++;
               }
               else if(movement.equalsIgnoreCase("w"))
                   {
                       positiony--;
                       if(map1[positiony][positionx]==1)
                       positiony++;
                   }
                   else if (movement.equalsIgnoreCase("S"))
                       {
                           positiony++;
                           if(map1[positiony][positionx]==1)
                           positiony--;
                       }
                       else if(movement.equalsIgnoreCase("d"))
                           {
                               positionx++;
                               if(map1[positiony][positionx]==1)
                               positionx--;
                           }
                           else if (movement.equalsIgnoreCase("e"))
                               {
                                   System.exit(0);
                               }
                               else if(movement.equalsIgnoreCase("R"))
                               {
                                   positionx = 55;
                                   positiony = 17;
                               }
                               else if(movement.equalsIgnoreCase("N"))
                                   {
                                       positionx = finishx;
                                       positiony = finishy;
                                   }

           }while (positionx!=finishx ||positiony!=finishy);
           System.out.println("Good Job, you have passed stage 1");
           input.nextLine();

           byte [][] map2 = {
           {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
           {1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
           {1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,1,1,1,1},
           {1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1},
           {1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1},
           {1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1},
           {1,1,1,0,0,0,1,1,1,1,1,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
           {1,0,0,0,0,0,0,0,0,0,0,0,0,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
           {1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1},
           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
           {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};
           //57,19

           byte positionx2 = 54, positiony2 = 17 , finishx2 = 2 , finishy2 = 1;
           String movement2 = "";
           String done2 = "";


           do
           {
               for (int i = 1 ; i <= 25 ; i++)
               System.out.println();
               for (int y = 0 ; y <= map2.length-1 ; y++)
               {
                   for (int x = 0 ; x <= map2[1].length-1 ; x++)
                   {
                       if (x == positionx2 && y == positiony2)
                       {
                           System.out.print(z);
                       }
                       else if(y == finishy2 && x == finishx2)
                           {
                               System.out.print("X");
                           }
                           else if (map2[y][x]==1)
                               {
                                   System.out.print("?");
                               }
                               else
                               {
                                   System.out.print(" ");
                               }
                       }
                   System.out.println();
               }
               System.out.println("W = up , A = left , S = down , D = right , E = Exit , R = Restart , N = Next");
               System.out.print("Input Movement = ");
               movement2 = input.nextLine();
               if (movement2.equalsIgnoreCase("a"))
               {
                   positionx2--;
                   if (map2[positiony2][positionx2]==1)
                   positionx2++;
               }
               else if(movement2.equalsIgnoreCase("w"))
                   {
                       positiony2--;
                       if(map2[positiony2][positionx2]==1)
                       positiony2++;
                   }
                   else if (movement2.equalsIgnoreCase("S"))
                       {
                           positiony2++;
                           if(map2[positiony2][positionx2]==1)
                           positiony2--;
                       }
                       else if(movement2.equalsIgnoreCase("d"))
                           {
                               positionx2++;
                               if(map2[positiony2][positionx2]==1)
                               positionx2--;
                           }
                           else if (movement2.equalsIgnoreCase("e"))
                               {
                                   System.exit(0);
                               }
                               else if(movement2.equalsIgnoreCase("R"))
                               {
                                   positionx2 = 55;
                                   positiony2 = 17;
                               }
                               else if (movement2.equalsIgnoreCase("N"))
                                   {
                                       positionx2 = finishx2;
                                       positiony2 = finishy2;
                                   }
           }while(positionx2!=finishx2 ||positiony2!=finishy2);

           System.out.println("Good Job, you have passed stage 2");
           input.nextLine();

           byte [][] map3 = {
           {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
           {1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
           {1,1,1,1,1,1,0,0,1,0,0,0,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,0,0,1,1,1,1,1,1,0,1,1,1,1,1,0,0,1},
           {1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,1},
           {1,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,0,0,0,1,0,0,1},
           {1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1},
           {1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1},
           {1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,0,0,0,1,1,1,1,0,1},
           {1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1},
           {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};

           byte positionx3 = 54, positiony3 = 17 , finishx3 = 2 , finishy3 = 1;
           String movement3 = "";
           String done3 = "";


           do
           {
               for (int i = 1 ; i <= 25 ; i++)
               System.out.println();
               for (int y = 0 ; y <= map3.length-1 ; y++)
               {
                   for (int x = 0 ; x <= map3[1].length-1 ; x++)
                   {
                       if (x == positionx3 && y == positiony3)
                       {
                           System.out.print(z);
                       }
                       else if(y == finishy3 && x == finishx3)
                           {
                               System.out.print("X");
                           }
                           else if (map3[y][x]==1)
                               {
                                   System.out.print("?");
                               }
                               else
                               {
                                   System.out.print(" ");
                               }
                       }
                   System.out.println();
               }
               System.out.println("W = up , A = left , S = down , D = right , E = Exit , R = Restart , N = Next");
               System.out.print("Input Movement = ");
               movement3 = input.nextLine();
               if (movement3.equalsIgnoreCase("a"))
               {
                   positionx3--;
                   if (map3[positiony3][positionx3]==1)
                   positionx3++;
               }
               else if(movement3.equalsIgnoreCase("w"))
                   {
                       positiony3--;
                       if(map3[positiony3][positionx3]==1)
                       positiony3++;
                   }
                   else if (movement3.equalsIgnoreCase("S"))
                       {
                           positiony3++;
                           if(map3[positiony3][positionx3]==1)
                           positiony3--;
                       }
                       else if(movement3.equalsIgnoreCase("d"))
                           {
                               positionx3++;
                               if(map3[positiony3][positionx3]==1)
                               positionx3--;
                           }
                           else if (movement3.equalsIgnoreCase("e"))
                               {
                                   System.exit(0);
                               }
                               else if(movement3.equalsIgnoreCase("R"))
                                   {
                                       positionx3 = 55;
                                       positiony3 = 17;
                                   }
                                   else if(movement3.equalsIgnoreCase("N"))
                                       {
                                           positionx3 = finishx3;
                                           positiony3 = finishy3;
                                       }
           }while(positionx3!=finishx3 ||positiony3!=finishy3);

           System.out.println("Good Job, you have passed all the stages");
           input.nextLine();

           do
           {
               System.out.print("Try Again <y/n> ? ");
               repeat = input.nextLine();
           }while (!repeat.equalsIgnoreCase("y") && !repeat.equalsIgnoreCase("N"));

       }while(repeat.equalsIgnoreCase("y"));

   }
}

Can somebody help on making comments/ annotations in this program so that it is easier to understand.

Thanks in advance!

Explanation / Answer

Note : in the given code the comments are added.

// import the required packages
import java.util.*;
// Class assignment
public class assignment
{
   // Main method
    public static void main(String[] args)
    {
       // Create a object for the scanner to read the input
        Scanner input = new Scanner(System.in);
        String repeat = "";

       // loop code for iterative process
        do
        {
            // Declare the byte array
           byte [][] map1 = {
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,0,1,1,1,1,1,0,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
            {1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1},
            {1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1},
            {1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
            {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};

           // Declare the required variables
            byte positionx = 54, positiony = 17 , finishx = 2 , finishy = 1;
            String z = "";
            String movement = "";
            String done = "";
          
           // loop block code for iterative process
            do
            {
               // loop iteration to print 25 new line
                for (int i = 1 ; i <= 25 ; i++)
                System.out.println();
               // loop code to y position
                for (int y = 0 ; y <= map1.length-1 ; y++)
                {
                   // loop code for x position
                    for (int x = 0 ; x <= map1[1].length-1 ; x++)
                    {
                       // Code to check the postion of x and y
                        if (x == positionx && y == positiony)
                        {
                           // code to print the symbol
                            System.out.print(z);
                        }
                       // Code to chech whether the position is finish
                        else if(y == finishy && x == finishx)
                            {
                                System.out.print("X");
                            }
                           // code to check the postion value is equal to 1
                            else if (map1[y][x]==1)
                            {
                               // Print the symbol
                                System.out.print("?");
                            }
                            else
                            {
                               // Print the blank space
                                System.out.print(" ");
                            }
                        }
                    System.out.println();
                }
               // Print options for the movement
                System.out.println("W = up , A = left , S = down , D = right , E = Exit , R = Restart , N = Next");
               // Read the user input
                System.out.print("Input Movement = ");
                movement = input.nextLine();
               // check the user input is "a" for left movement
                if (movement.equalsIgnoreCase("a"))
                {
                   // Decrease position value
                    positionx--;
                   // Check the map position is equal to 1
                    if (map1[positiony][positionx]==1)
                   // Increase the position value  
                    positionx++;
                }
               // check the user input is "w" for upside movement
                else if(movement.equalsIgnoreCase("w"))
               {
                   // Decrease position value
                   positiony--;
                   // Check the map position is equal to 1
                   if(map1[positiony][positionx]==1)
                   positiony++;
               }
               // check the user input is "s" for downside movement
               else if (movement.equalsIgnoreCase("S"))
               {
                   // Increase position value
                   positiony++;
                   // Check the map position is equal to 1
                   if(map1[positiony][positionx]==1)
                   // Decrease position value
                   positiony--;
               }
               // check the user input is "d" for rightside movement
               else if(movement.equalsIgnoreCase("d"))
               {
                   // Increase position value
                   positionx++;
                   // Check the map position is equal to 1
                   if(map1[positiony][positionx]==1)
                   // Increase position value
                   positionx--;
               }
               // check the user input is "e" for exit
               else if (movement.equalsIgnoreCase("e"))
               {
                   // exit from the process
                   System.exit(0);
               }
               // check the user input is "R" for restart
               else if(movement.equalsIgnoreCase("R"))
               {
                   // Assign the position X and y value
                   positionx = 55;
                   positiony = 17;
               }
               // check the user input is "N" for next
               else if(movement.equalsIgnoreCase("N"))
               {
                   // Assign the finish position value
                   positionx = finishx;
                   positiony = finishy;
               }
           // While loop to check position reached the end
            }while (positionx!=finishx ||positiony!=finishy);
            System.out.println("Good Job, you have passed stage 1");
            input.nextLine();

           // Initialize the map2 value
            byte [][] map2 = {
            {1,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1,1,1,1,1,1,1,0,0,0,0,1},
            {1,0,0,1,0,0,1,0,0,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,1},
            {1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
            {1,0,0,0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1},
            {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1},
            {1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,1,1,1,0,1,0,0,1,0,0,0,0,0,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1},
            {1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1},
            {1,0,0,1,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
            {1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1},
            {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};
            //57,19

           // Declare the required value
            byte positionx2 = 54, positiony2 = 17 , finishx2 = 2 , finishy2 = 1;
            String movement2 = "";
            String done2 = "";

           // loop block code for iterative process
            do
            {
               // loop iteration to print 25 new line
                for (int i = 1 ; i <= 25 ; i++)
                System.out.println();
               // loop code to y position
                for (int y = 0 ; y <= map2.length-1 ; y++)
                {
                   // loop code for x position
                    for (int x = 0 ; x <= map2[1].length-1 ; x++)
                    {
                       // Code to check the postion of x and y
                        if (x == positionx2 && y == positiony2)
                        {
                           // code to print the symbol
                            System.out.print(z);
                        }
                       // Code to chech whether the position is finish
                        else if(y == finishy2 && x == finishx2)
                       {
                           // code to check the postion value is equal to 1
                           System.out.print("X");
                       }
                       // code to check the postion value is equal to 1
                       else if (map2[y][x]==1)
                       {
                           // Print the symbol
                           System.out.print("?");
                       }
                       else
                       {
                           // Print the blank space
                           System.out.print(" ");
                       }
                    }
                    System.out.println();
                }
               // Print options for the movement
                System.out.println("W = up , A = left , S = down , D = right , E = Exit , R = Restart , N = Next");
                // Read the user input
               System.out.print("Input Movement = ");
                movement2 = input.nextLine();
               // check the user input is "a" for left movement
                if (movement2.equalsIgnoreCase("a"))
                {
                    positionx2--;
                    if (map2[positiony2][positionx2]==1)
                    positionx2++;
                }
               // check the user input is "w" for upside movement
                else if(movement2.equalsIgnoreCase("w"))
                    {
                        positiony2--;
                        if(map2[positiony2][positionx2]==1)
                        positiony2++;
                    }
                   // check the user input is "s" for downside movement
                    else if (movement2.equalsIgnoreCase("S"))
                        {
                            positiony2++;
                            if(map2[positiony2][positionx2]==1)
                            positiony2--;
                        }
                       // check the user input is "d" for rightside movement
                        else if(movement2.equalsIgnoreCase("d"))
                            {
                                positionx2++;
                                if(map2[positiony2][positionx2]==1)
                                positionx2--;
                            }
                           // check the user input is "e" for exit
                            else if (movement2.equalsIgnoreCase("e"))
                                {
                                    System.exit(0);
                                }
                               // check the user input is "R" for restart
                                else if(movement2.equalsIgnoreCase("R"))
                                {
                                    positionx2 = 55;
                                    positiony2 = 17;
                                }
                               // check the user input is "N" for next
                                else if (movement2.equalsIgnoreCase("N"))
                                    {
                                        positionx2 = finishx2;
                                        positiony2 = finishy2;
                                    }
            }while(positionx2!=finishx2 ||positiony2!=finishy2);

            System.out.println("Good Job, you have passed stage 2");
            input.nextLine();
               // Initialize the map2 value
            byte [][] map3 = {
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
            {1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
            {1,1,1,1,1,1,0,0,1,0,0,0,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,0,0,1,1,1,1,1,1,0,1,1,1,1,1,0,0,1},
            {1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,1},
            {1,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,0,0,0,1,0,0,1},
            {1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1},
            {1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,0,0,0,1,0,0,0,0,0,1},
            {1,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,0,1,1},
            {1,0,0,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,1,0,0,1,1,0,1,0,0,0,0,0,0,1},
            {1,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,1,1,1,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,1},
            {1,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,1,1,1,1,1,0,1},
            {1,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,0,0,1,0,0,1,1,0,1,0,0,0,0,0,0,0,1,1,1},
            {1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,0,0,1,1,1,1,0,1,0,1},
            {1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1,0,0,1,0,1},
            {1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1,0,0,1,0,1},
            {1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1},
            {1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,0,0,0,1,1,1,1,0,1},
            {1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1},
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};

            byte positionx3 = 54, positiony3 = 17 , finishx3 = 2 , finishy3 = 1;
            String movement3 = "";
            String done3 = "";


            do
            {
                for (int i = 1 ; i <= 25 ; i++)
                System.out.println();
                for (int y = 0 ; y <= map3.length-1 ; y++)
                {
                    for (int x = 0 ; x <= map3[1].length-1 ; x++)
                    {
                        if (x == positionx3 && y == positiony3)
                        {
                            System.out.print(z);
                        }
                        else if(y == finishy3 && x == finishx3)
                            {
                                System.out.print("X");
                            }
                            else if (map3[y][x]==1)
                                {
                                    System.out.print("?");
                                }
                                else
                                {
                                    System.out.print(" ");
                                }
                        }
                    System.out.println();
                }
               // Print options for the movement
                System.out.println("W = up , A = left , S = down , D = right , E = Exit , R = Restart , N = Next");
                System.out.print("Input Movement = ");
                movement3 = input.nextLine();
               // check the user input is "a" for left movement
                if (movement3.equalsIgnoreCase("a"))
                {
                    positionx3--;
                    if (map3[positiony3][positionx3]==1)
                    positionx3++;
                }
               // check the user input is "w" for upside movement
                else if(movement3.equalsIgnoreCase("w"))
                    {
                        positiony3--;
                        if(map3[positiony3][positionx3]==1)
                        positiony3++;
                    }
                   // check the user input is "s" for downside movement
                    else if (movement3.equalsIgnoreCase("S"))
                        {
                            positiony3++;
                            if(map3[positiony3][positionx3]==1)
                            positiony3--;
                        }
                       // check the user input is "d" for rightside movement
                        else if(movement3.equalsIgnoreCase("d"))
                            {
                                positionx3++;
                                if(map3[positiony3][positionx3]==1)
                                positionx3--;
                            }
                           // check the user input is "e" for exit
                            else if (movement3.equalsIgnoreCase("e"))
                                {
                                    System.exit(0);
                                }
                               // check the user input is "R" for restart
                                else if(movement3.equalsIgnoreCase("R"))
                                    {
                                        positionx3 = 55;
                                        positiony3 = 17;
                                    }
                                   // check the user input is "N" for next
                                    else if(movement3.equalsIgnoreCase("N"))
                                        {
                                            positionx3 = finishx3;
                                            positiony3 = finishy3;
                                        }
           // While loop to check position reached the end
            }while(positionx3!=finishx3 ||positiony3!=finishy3);
           // Get the user option to continue
            System.out.println("Good Job, you have passed all the stages");
            input.nextLine();
           // Loop to repeatedly get user choice
            do
            {
                System.out.print("Try Again <y/n> ? ");
                repeat = input.nextLine();
           // Check user choice
            }while (!repeat.equalsIgnoreCase("y") && !repeat.equalsIgnoreCase("N"));
       // Check user choice
        }while(repeat.equalsIgnoreCase("y"));

    }
}