Ask Question

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. 10 November, 05:23
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers