15.5k views
2 votes
. [Method 1] In the Main class, write a static void method to print the following text by

making use of a loop. Solutions without a loop will receive no credit.
output should look like this:
1: All work and no play makes Jack a dull boy.
2: All work and no play makes Jack a dull boy.
3: All work and no play makes Jack a dull boy.
4: All work and no play makes Jack a dull boy

User Roubi
by
6.9k points

1 Answer

4 votes

Answer:

The method is as follows:

static void printt() {

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

System.out.println(i+": All work and no play makes Jack a dull boy.");

}

}

Step-by-step explanation:

This line defines the method

static void printt() {

This line iterates through 1 to 4

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

This line prints the required output

System.out.println(i+": All work and no play makes Jack a dull boy.");

}

}

User Alfred Xing
by
6.4k points