Write this class so that it defines a runnable Java program

Write this class so that it defines a runnable Java program that will print out grammatically-correct lyrics to \"10 Little Monkeys\". You should use a loop to print out the lyrics. Since the results must be grammatically correct, make certain your code prints out 1 little monkey and not 1 little monkeys.

package edu.buffalo.cse116;

public class Monkeys {
  

}

Solution

Hi, Please find my implementation.

public class Monkey {

  

   public static void main(String[] args) {

      

       String messageOther= \" Little Monkeys\";

       String messageone = \" Little Monkey\";

      

       for(int i=1; i<=10; i++){

          

           if(i == 1)

               System.out.println(i+messageone);

           else

               System.out.println(i+messageOther);

       }

   }

}

/*

Sample run:

1 Little Monkey

2 Little Monkeys

3 Little Monkeys

4 Little Monkeys

5 Little Monkeys

6 Little Monkeys

7 Little Monkeys

8 Little Monkeys

9 Little Monkeys

10 Little Monkeys

*/

Write this class so that it defines a runnable Java program that will print out grammatically-correct lyrics to \
Write this class so that it defines a runnable Java program that will print out grammatically-correct lyrics to \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site