title: How to add the current iteration's value to the previous iteration's value in a loop
body: <pre><code>public class Recount {
      /**
       * @param args the command line arguments
       */
      public static void main(String[] args) {
          Random rand = new Random();
          boolean s = false;
          int a;
          Scanner quest = new Scanner(System.in);
  
          do {
              int n = rand.nextInt(100) + 1;
              System.out.println(n);
              System.out.println("Try again?");
              s = quest.nextBoolean();
          } while (s != false);
      }
  }
  </code></pre>
  
  <p>I want to add the number that was given in the previous iteration to the number in the current iteration of the loop.</p>
  
  <p>Basically I want new n to be equal to old random number + new random number.</p>