title: How to add information from if-else statements to an array Java
body: <p>I'm new to Java, currently, I'm learning arrays and loops.
  I have an interesting task from my homework.</p>
  <p>Write a program that will multiply each price passed:</p>
  <p>By 2 if the price of the goods is less than 1000.
  By 1.5 if the price of the goods is greater than or equal to 1000.</p>
  <p>The task:</p>
  <p>Write the method <code>public void multiple prices (float [] prices)</code>.
  It takes an array of prices, and multiplies each price by 2 if the price is less than 1000, and by 1.5 if the price is greater than or equal to 1000.</p>
  <p>Examples of tests:</p>
  <p>Calling <code>multiplyPrices()</code> with data <code>[100, 1500]</code> should change the transmitted array to <code>[200, 2250]</code>.</p>
  <p>And here I'm stuck =(</p>
  <p>I wrote a code that takes an array, converts it to float, takes its value, and checks it with the if-else statement, the only problem is that I don't know how to put it back.</p>
  <p>My classmate says that it looks as if I calculate the correct values and immediately display them in the console without changing the data of the price array.
  The program at the end displays the value of the array, and that's why I get such a result.
  It is necessary not to print <code>x1</code> and <code>x3</code> to the console, and I need to save <code>x1</code> and <code>x3</code> in an array of prices under the index <code>i</code>. Then, when checking the task, the &quot;correct&quot; should be displayed.</p>
  <p>But how can this be done?
  Unfortunately with if-else, the data could be extracted neither back, nor forward.</p>
  <p>Can you give some advice?</p>
  <p>Thank you in advance!</p>
  <pre class="lang-java prettyprint-override"><code>import java.util.Arrays;
  
  public class QuadraticEquationSolver {
      
      public void multiplyPrices(float[] prices) {
          
          for (int i = 0; i &lt; prices.length; i++) {           
              float season = prices[i];
              
                  if (season &gt;= 1000) {   
                      float x1 = season * 1.5f;
                      float x2 [] = new float[] {x1};
                      System.out.print(Arrays.toString(x2));
                      
                  } else if (season &lt; 1000 ) {
                      float x3 = season * 2f;
                      float x4 [] = new float[] {x3};
                      System.out.print(Arrays.toString(x4));
              }   
          }
      }
  
      
      public static void main(String[] args) {
          QuadraticEquationSolver shop = new QuadraticEquationSolver();
  
          //Should be [200, 2250]
          float[] prices = new float[] {100f, 1500f};
          shop.multiplyPrices(prices);
          System.out.println(Arrays.toString(prices));
      }
  }
  </code></pre>