Ask Question
26 August, 11:40

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

+2
Answers (1)
  1. 26 August, 13:59
    0
    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);

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a method printSquare that accepts min and max integers and prints a square of lines of increasing numbers. The first line should ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers