title: How to convert for loop to do-while loop?
body: <p>This is a question from the book <em>Introduction to Java</em> by Y Daniel Liang:</p>
  <blockquote>
  <p>Convert for  loop statement to a while loop and do-while loop?</p>
  <pre><code>int sum = 0; 
  for (int i = 0; i &lt;= 7; i++) 
      sum = sum + i; 
  </code></pre>
  </blockquote>
  <p>I am pretty confused on how to convert it to a do-while loop. What am I supposed to do? Please see my code below.</p>
  <pre><code>public class Convert_forLoop_toWhileLoop {
      
     public static void main(String[] args) {
         int sum = 0;
         int i = 0;
         do {
             sum = sum + i;
             System.out.println(sum);
             i++;
         } while(i &lt;= 7); 
      }
  }
  </code></pre>