class MonkeyLoop {

    String [][] monkeys;    
    
    public MonkeyLoop() {
        monkeys = new String[][]{   
            //Monkey 0
            {
                    "ʕง ͠° ͟ل͜ ͡°)ʔ ",      //[0][0] eyes
                    "  \\_⏄_/  ",      //[0][1] chin
                    "  --0--   ",       //[0][2] body
                    "  ⎛   ⎞   ",        //[0][3] legs
                    "  Alice   "       //[0][4] name
            },
            //Monkey 1
            {
                    " ʕ༼ ◕_◕ ༽ʔ",       //[1][0]
                    "  \\_⎏_/  ",
                    "  ++1++  ",
                    "   ⌋ ⌊   ",
                    "  Iris   "
            },
            //Monkey 2
            {
                    " ʕ(▀ ⍡ ▀)ʔ",       //[2][0]
                    "  \\_⎐_/ ",
                    "  <-2->  ",
                    "  〈  〉 ",
                    "  Samaya   "
            },
            //Monkey 3
            {
                    "ʕ ͡° ͜ʖ ° ͡ʔ",        //[3][0]
                    "  \\_⍾_/  ",
                    "  ==3==  ",
                    "  _/ \\_  ",
                    " Sarayu   "
            },
            //Monkey 4
            {
                    "  (◕‿◕✿) ",          //[4][0]
                    "  \\_⍾_/ ",          //[4][1]
                    "  ==4==  ",          //[4][2]
                    "  _/ \\_ ",           //[4][3]
                    "  Mort   "          //[4][4]
            },

        };
    }


    public void printPoem() {
        System.out.println();
        System.out.println("Monkey Jumpers Poem in Java Loopy");

        // monkeys (non-primitive) defined in constructor knows its length
        int monkeyCount = monkeys.length;
        for (int i = monkeyCount; i >= 1; i--)  //loops through 2D array length backwards
        {

            for (int row = 0; row < monkeyCount; row++) {  

                for (int col = 0; col < monkeys[row].length; col++) {
                    System.out.print(monkeys[row][col] + " ");
                    System.out.println();
                }
                System.out.println();
            }

            if (i > 1){
                System.out.println(i + " little monkeys jumping on the bed...");
            }
            else{
                System.out.println(i + " little monkey jumping on the bed...");
            }
            
            System.out.println("One fell down and bumped his head!");
            System.out.println("Mama called the doctor and the doctor said,");
            if (i == 1){   
                System.out.println("Put those monkeys right to bed!");
            }
            else{
                System.out.println("No more monkeys jumping on the bed!");
            }
            System.out.println();
            monkeyCount -= 1;
        }

        System.out.println("Now there's no little monkeys jumping on the bed");
        System.out.println("------------------------------------------------");
        System.out.println("                    THE END                    ");
    }

    public static void main(String[] args)  {
        new MonkeyLoop().printPoem();   
    }

}
MonkeyLoop.main(null);
Monkey Jumpers Poem in Java Loopy
ʕง ͠° ͟ل͜ ͡°)ʔ  
  \_⏄_/   
  --0--    
  ⎛   ⎞    
  Alice    

 ʕ༼ ◕_◕ ༽ʔ 
  \_⎏_/   
  ++1++   
   ⌋ ⌊    
  Iris    

 ʕ(▀ ⍡ ▀)ʔ 
  \_⎐_/  
  <-2->   
  〈  〉  
  Samaya    

ʕ ͡° ͜ʖ ° ͡ʔ 
  \_⍾_/   
  ==3==   
  _/ \_   
 Sarayu    

  (◕‿◕✿)  
  \_⍾_/  
  ==4==   
  _/ \_  
  Mort    

5 little monkeys jumping on the bed...
One fell down and bumped his head!
Mama called the doctor and the doctor said,
No more monkeys jumping on the bed!

ʕง ͠° ͟ل͜ ͡°)ʔ  
  \_⏄_/   
  --0--    
  ⎛   ⎞    
  Alice    

 ʕ༼ ◕_◕ ༽ʔ 
  \_⎏_/   
  ++1++   
   ⌋ ⌊    
  Iris    

 ʕ(▀ ⍡ ▀)ʔ 
  \_⎐_/  
  <-2->   
  〈  〉  
  Samaya    

ʕ ͡° ͜ʖ ° ͡ʔ 
  \_⍾_/   
  ==3==   
  _/ \_   
 Sarayu    

4 little monkeys jumping on the bed...
One fell down and bumped his head!
Mama called the doctor and the doctor said,
No more monkeys jumping on the bed!

ʕง ͠° ͟ل͜ ͡°)ʔ  
  \_⏄_/   
  --0--    
  ⎛   ⎞    
  Alice    

 ʕ༼ ◕_◕ ༽ʔ 
  \_⎏_/   
  ++1++   
   ⌋ ⌊    
  Iris    

 ʕ(▀ ⍡ ▀)ʔ 
  \_⎐_/  
  <-2->   
  〈  〉  
  Samaya    

3 little monkeys jumping on the bed...
One fell down and bumped his head!
Mama called the doctor and the doctor said,
No more monkeys jumping on the bed!

ʕง ͠° ͟ل͜ ͡°)ʔ  
  \_⏄_/   
  --0--    
  ⎛   ⎞    
  Alice    

 ʕ༼ ◕_◕ ༽ʔ 
  \_⎏_/   
  ++1++   
   ⌋ ⌊    
  Iris    

2 little monkeys jumping on the bed...
One fell down and bumped his head!
Mama called the doctor and the doctor said,
No more monkeys jumping on the bed!

ʕง ͠° ͟ل͜ ͡°)ʔ  
  \_⏄_/   
  --0--    
  ⎛   ⎞    
  Alice    

1 little monkey jumping on the bed...
One fell down and bumped his head!
Mama called the doctor and the doctor said,
Put those monkeys right to bed!

Now there's no little monkeys jumping on the bed
------------------------------------------------
                    THE END                    

Horizontal vs Vertical

Printing monkeys horizontally vs vertically. I switched the order of the for loops. The row loop goes inside of the colomn loop in order to print the monkeys horizontally, and vice versa for vertically.

class MonkeyLoop {
    String [][] monkeys;    
    
    public MonkeyLoop() {
        monkeys = new String[][]{   
            //Monkey 0
            {
                    "ʕง ͠° ͟ل͜ ͡°)ʔ",      //[0][0] eyes
                    "  \\_⏄_/   ",      //[0][1] chin
                    "  --0--    ",       //[0][2] body
                    "  ⎛   ⎞    "        //[0][3] legs
            },
            //Monkey 1
            {
                    " ʕ༼ ◕_◕ ༽ʔ ",       //[1][0]
                    "  \\_⎏_/   ",
                    "  ++1++    ",
                    "   ⌋ ⌊     "
            },
            //Monkey 2
            {
                    " ʕ(▀ ⍡ ▀)ʔ ",       //[2][0]
                    "   \\_⎐_/   ",
                    "  <-2->    ",
                    "  〈  〉    "
            },
            //Monkey 3
            {
                    "  ʕ ͡° ͜ʖ ° ͡ʔ  ",        //[3][0]
                    "   \\_⍾_/   ",
                    "  ==3==    ",
                    "  _/ \\_   "
            },
            //Monkey 4
            {
                    "  (◕‿◕✿)   ",          //[4][0]
                    "   \\_⍾_/   ",          //[4][1]
                    "  ==4==    ",          //[4][2]
                    "  _/ \\_   "           //[4][3]
            },

        };
    }


    public void printPoem() {
        System.out.println();
        System.out.println("Monkey Jumpers Poem in Java Loopy");


        int monkeyCount = monkeys.length;
        for (int i = monkeyCount; i >= 1; i--)
        {
            System.out.println(i + " little monkeys jumping on the bed...");
 
            for (int col = 0; col < monkeys[col].length; col++)  {  

                for (int row = 0; row < monkeyCount; row++) {

                    System.out.print(monkeys[row][col] + "    ");

                }

                System.out.println();
            }

            monkeyCount -= 1;
        }

        System.out.println("No more monkeys jumping on the bed");
        System.out.println("----------------------------------");
        System.out.println("             THE END              ");
    }

    public static void main(String[] args)  {
        new MonkeyLoop().printPoem(); 
    }

}
MonkeyLoop.main(null);
Monkey Jumpers Poem in Java Loopy
5 little monkeys jumping on the bed...
ʕง ͠° ͟ل͜ ͡°)ʔ     ʕ༼ ◕_◕ ༽ʔ      ʕ(▀ ⍡ ▀)ʔ       ʕ ͡° ͜ʖ ° ͡ʔ        (◕‿◕✿)       
  \_⏄_/         \_⎏_/          \_⎐_/          \_⍾_/          \_⍾_/       
  --0--          ++1++          <-2->          ==3==          ==4==        
  ⎛   ⎞           ⌋ ⌊           〈  〉          _/ \_         _/ \_       
4 little monkeys jumping on the bed...
ʕง ͠° ͟ل͜ ͡°)ʔ     ʕ༼ ◕_◕ ༽ʔ      ʕ(▀ ⍡ ▀)ʔ       ʕ ͡° ͜ʖ ° ͡ʔ      
  \_⏄_/         \_⎏_/          \_⎐_/          \_⍾_/       
  --0--          ++1++          <-2->          ==3==        
  ⎛   ⎞           ⌋ ⌊           〈  〉          _/ \_       
3 little monkeys jumping on the bed...
ʕง ͠° ͟ل͜ ͡°)ʔ     ʕ༼ ◕_◕ ༽ʔ      ʕ(▀ ⍡ ▀)ʔ     
  \_⏄_/         \_⎏_/          \_⎐_/       
  --0--          ++1++          <-2->        
  ⎛   ⎞           ⌋ ⌊           〈  〉        
2 little monkeys jumping on the bed...
ʕง ͠° ͟ل͜ ͡°)ʔ     ʕ༼ ◕_◕ ༽ʔ     
  \_⏄_/         \_⎏_/       
  --0--          ++1++        
  ⎛   ⎞           ⌋ ⌊         
1 little monkeys jumping on the bed...
ʕง ͠° ͟ل͜ ͡°)ʔ    
  \_⏄_/       
  --0--        
  ⎛   ⎞        
No more monkeys jumping on the bed
----------------------------------
             THE END              

Hacks Questions

  • In imperative programming, functions are implicitly coded in every step required to solve a problem. Every operation is coded and the code itself specifies how the problem is to be solved, which means that pre-coded models are not called on.
  • Is this program in more of an Imperative Programming Style or OOP Style? Explain. Even though this program has some properties of OOP such as objects (the array) specific to the monkeyloop class and a constructor, it is more like the imperative programming style. Every step needed to run the program is coded in the printPoem function and the single command in main is just to run that method.

  • Are the monkeys objects? Yes. Arrays are objects and even though in this program their content is not being alterned. You can still manipulate the data in the monkey array through the index if you wanted to

  • How to access 2-D arrays? You can access the 2-D array by using the row index value and column index value: Name_of_the Array[Row_index][Column_index];

  • In this program the row represented the monkey number and the colomn represented each body part