Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a looping square with java
    primarykey
    data
    text
    <p>Full Disclosure: Homework.</p> <p>Explanation: I cant understand my teacher.</p> <p>Problem:</p> <blockquote> <p>Write a method called <code>printSquare</code> that takes in two integer parameters, a <code>min</code> and a <code>max</code>, and prints the numbers in the range from <code>min</code> to <code>max</code> inclusive in a square pattern. The square pattern is easier to understand by example than by explanation, so take a look at the sample method calls and their resulting console output in the table below. Each line of the square consists of a circular sequence of increasing integers between <code>min</code> and <code>max</code>. Each line prints a different permutation of this sequence. The first line begins with min, the second line begins with <code>min + 1</code>, and so on. When the sequence in any line reaches <code>max</code>, it wraps around back to <code>min</code>. You may assume the caller of the method will pass a <code>min</code> and a <code>max</code> parameter such that <code>min</code> is less than or equal to <code>max</code></p> </blockquote> <p><img src="https://i.stack.imgur.com/9tjT5.png" alt="enter image description here"></p> <p>I cannot for the life of me figure out how to make the numbers stop at the 'max' value and start over in the middle of the line.</p> <p>This is what I have so far, apologies but I have trouble with for loops.</p> <pre><code>for(int i = 0; i &lt; row; i++) { for(int d = 0; d &lt; row; d++) { System.out.print(d+1); } System.out.println(i); } </code></pre> <p>I know I used row twice, but its the only way i can get the compiler to form a square shape with the loop. Does anyone even remotely understand what i'm trying to do? :/</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload