why are my variable not adding together in these for statements?
<p>I'm working on some beginning Java logic, and I'm not sure why this is not working.  Here is a method I made:</p>

<pre><code>private void printSubclassBoxes(){
        int  coordinateX = ((getWidth() - BOX_WIDTH) /4);

        for ( int i = 0; i &lt; 3; i++){

            double coordinateY = (getHeight() / 2);     
            GRect classBox = new GRect (coordinateX, coordinateY, BOX_WIDTH, BOX_HEIGHT);

            GLabel classLabel = new GLabel ("Program");
            double labelCoordinateX = (coordinateX + ((classBox.getWidth() / 2) - (classLabel.getWidth() / 2)));
            double labelCoordinateY = (coordinateY + ((classBox.getHeight() / 2) + (classLabel.getAscent() / 2)));
            add(classBox);
            add(classLabel, labelCoordinateX, labelCoordinateY);
            if (i == 1){
            coordinateX = (((getWidth() - BOX_WIDTH) /4) * 2);
        } 
        if (i == 2){
            coordinateX = (((getWidth() - BOX_WIDTH) /4) * 3);
        } 

        }   

    }
</code></pre>

<p>Now I'm sure there are probably better ways to do this, but please-I'm not interested in that right now (I'm trying to learn without being spoonfed the answers).  All I am wanting to know is why the ending two if statements are not working like I think they should. </p>

<p>For simplicity sake, let's say  </p>

<pre><code>100 = ((getWidth() - BOX_WIDTH)

int coordinateX = 25;
</code></pre>

<p>My understanding is that <code>int i</code> gets to that first if statement and adds 25 + 25 so then coordinateX = 50.</p>

<p>then next time in the loop, i = 2 so coordinateX would = 75. </p>

<p>This is what I'm expecting to happen, but it's not.  I seem to be printing the first two boxes directly on top of each other, and then the third is moving 25.  </p>

<p>Thanks for your help guys.  Now that I got that loop figured out, I went ahead and solved it a different way.  I ended up assigning coordinateX to another variable and using that to add to the end:</p>

<pre><code>int  coordinateX = ((getWidth() - BOX_WIDTH) /4);
        int otherCoordinateX = coordinateX;

        for ( int i = 0; i &lt; 3; i++){

            double coordinateY = (getHeight() / 2);     
            GRect classBox = new GRect (coordinateX, coordinateY, BOX_WIDTH, BOX_HEIGHT);

            GLabel classLabel = new GLabel ("Program");
            double labelCoordinateX = (coordinateX + ((classBox.getWidth() / 2) - (classLabel.getWidth() / 2)));
            double labelCoordinateY = (coordinateY + ((classBox.getHeight() / 2) + (classLabel.getAscent() / 2)));
            add(classBox);
            add(classLabel, labelCoordinateX, labelCoordinateY);
            coordinateX = otherCoordinateX + coordinateX;

        }   
</code></pre>
