title: Is there a way to have a single for loop return different values for different user inputs?
body: <p>I am trying to create a single for-loop that uses the variable 'lapTime' to store the current lapTime for hypothetical skiers. The skiers are to complete 5 laps and each lap there is a slow rate of 10%. The method I am writing should allow the user to input their lap number and my for loop should predict the time that the skier will finish their lap.</p>
  
  <p>slowRate Formula:</p>
  
  <pre><code>nextLapTime = previous lap time + (previous lap time * slowrate);
  </code></pre>
  
  <p>I tried using "if-else" statements in the for loop to force it to return different values that are dependent on the users lapNumber input, but that only breaks the for-loop (dead code error). 
  Currently, the for-loop only returns one value for each time it iterates through the loop -- 11 seconds. I've tried doing: <code>lapTime = lapTime  + (lapTime * slowRate)</code>, but that returns 16.(numbers) for whatever weird reason. Even though lapTime should be set equal to firstLapTime which == 10. The code I have provided below returns a value of 15 -- idk why..</p>
  
  <p>The For-Loop:</p>
  
  <pre><code>public double getLapTime(double firstLapTime, double slowRate, int lapNumber) 
  
      double lapTime;
      lapTime = firstLapTime;
      for (lapNumber=1; lapNumber&lt;=5; lapNumber ++) {
          lapTime = lapTime + (firstLapTime * slowRate);
      }
      return lapTime;
      }
  </code></pre>
  
  <p>Here are the test methods that I am trying to debug -- </p>
  
  <p>1) </p>
  
  <pre><code>public void testShouldHaveSecondLapOf11Seconds() {
  
      // Act: call our method with proper parameter value for our test
      double actualResult = theCalculator.getLapTime(10, .1, 2);
  
      // Assert: assert that our expected value is equal to the actual result
      assertEquals(11.0, actualResult, 0.001);
  </code></pre>
  
  <p>2) </p>
  
  <pre><code>public void testShouldHaveThirdLapOf12Point1Seconds() {
  
      // Act: call our method with proper parameter value for our test
      double actualResult = theCalculator.getLapTime(10, .1, 3);
  
      // Assert: assert that our expected value is equal to the actual result
      assertEquals(12.1, actualResult, 0.001);
  }
  </code></pre>
  
  <p>I am expecting to receive the values as shown in the JUnit tests, and somehow 
  the logic in my for-loop is not returning the lapTimes that it should. It returns only one number for each iteration of the loop.</p>
  
  <p>PS.. this is one of my first posts, so sorry in advance for any formatting issues. I'll try my best to improve on that. Thanks! </p>