title: 5.16 LAB: Adjust list by normalizing _ zybook - Java
body: <p>5.16 LAB: Adjust list by normalizing
  When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This adjustment can be done by normalizing to values between 0 and 1, or throwing away outliers.</p>
  <p>For this program, adjust the values by dividing all values by the largest value. The input begins with an integer indicating the number of floating-point values that follow. Assume that the list will always contain fewer than 20 floating-point values.</p>
  <p>Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
  System.out.printf(&quot;%.2f&quot;, yourValue);</p>
  <p>Ex: If the input is:</p>
  <p>5 30.0 50.0 10.0 100.0 65.0
  the output is:</p>
  <p>0.30 0.50 0.10 1.00 0.65
  The 5 indicates that there are five floating-point values in the list, namely 30.0, 50.0, 10.0, 100.0, and 65.0. 100.0 is the largest value in the list, so each value is divided by 100.0.</p>
  <p>For coding simplicity, follow every output value by a space, including the last one.</p>
  <p>I have been confused about how to do floating-point values in arrays and loops as in my book it never went over that.</p>
  <pre><code>  Scanner scnr = new Scanner(System.in);
    double numElements; 
    numElements = scnr.nextDouble(); 
    double [] userList = new double [numElements]; 
    int i; 
    double maxValue; 
    
    for (i = 0; i &lt; userList.length; ++i) { 
       userList[i] = scnr.nextDouble(); 
    } 
    
    maxValue = userList[i]; 
    for (i = 0; i &lt; userList.length; ++i) { 
       if (userList[i] &gt; maxValue) { 
          maxValue = userList[i]; 
       } 
    } 
    
    for (i = 0; i &lt; userList.length; ++i) { 
       userList[i] = userList[i] / maxValue; 
       System.out.print(userList[i] + &quot; &quot;); 
       System.out.printf(&quot;%.2f&quot;, userList[i]);
    } 
    
  </code></pre>
  <p>}
  }</p>
  <p>It's outputting:</p>
  <pre><code>LabProgram.java:8: error: incompatible types: possible lossy conversion from double to int
    double [] userList = new double [numElements]; 
  </code></pre>
  <p>I am confused about how to move forward, any help will be much appreciated!</p>