Write a method printSquare that accepts min and max integers and prints a square of lines of increasing numbers. The first line should start with the minimum; each line that follows should start with the next-higher number. The numbers on a line wrap back to the minimum after it hits the maximum. For example, the call: printSquare3, 6); should produce the following output: 3456 4563 5634 6345

Respuesta :

Answer:

public class PrintSquare {

   public static void printSquare(int min, int max) {

       for (int i = min; i <= max; i++) {

           for (int j = 0; j < (max - min + 1); j++) {

               if (i + j <= max)

                   System.out.print(i + j);

               else

                   System.out.print(i+j - max + min - 1);

           }

           System.out.println();

       }

   }

   public static void main(String[] args) {

       printSquare(3, 6);

   }

}

Explanation:

ACCESS MORE