title: while loop. sum and product of user inputted numbers
body: <p>Build a program that will generate the sum and product of 20 input numbers using the while…loop structure.</p>
  
  <p>Conditions:</p>
  
  <ul>
  <li>user need to input only 20 numbers</li>
  <li>and get the sum and product of all the numbers.</li>
  </ul>
  
  <p>My code right now is this</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Case3 {
      public static void main(String[] args) {
          Scanner input = new Scanner(System.in);
          int[] list = new int[20];
          int sum = 0;
          int product = 0;
          int x = 0;
          int number;
  
          System.out.print("Add number " + (x + 1) + ": ");
          number = input.nextInt();
  
          while (x &lt;= list.length) {
               list[x] = number;
               x++;
               System.out.print("Add number " + (x + 1) + ": ");
               number = input.nextInt();
          }
  
          for (int i = 0; i &lt; x; i++) {
               sum += list[i];
               product *=list[i];
          }
  
          System.out.println("The sum of all values are: " + sum);
          System.out.println("The product of all values are: " + product);
        }
  
  }  
  </code></pre>
  
  <blockquote>
    <p>--------------------Configuration: --------------------</p>
    
    <p>Add number 1: 1</p>
    
    <p>Add number 2: 2</p>
    
    <p>Add number 3: 3</p>
    
    <p>Add number 4: 4</p>
    
    <p>Add number 5: 5</p>
    
    <p>Add number 6: 6</p>
    
    <p>Add number 7: 7</p>
    
    <p>Add number 8: 8</p>
    
    <p>Add number 9: 9</p>
    
    <p>Add number 10: 10</p>
    
    <p>Add number 11: 11</p>
    
    <p>Add number 12: 12</p>
    
    <p>Add number 13: 13</p>
    
    <p>Add number 14: 14</p>
    
    <p>Add number 15: 15</p>
    
    <p>Add number 16: 16</p>
    
    <p>Add number 17: 17</p>
    
    <p>Add number 18: 18</p>
    
    <p>Add number 19: 19</p>
    
    <p>Add number 20: 20</p>
    
    <p>Add number 21: 21</p>
    
    <p>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
    20
        at Case3.main(Case3.java:16)</p>
    
    <p>Process completed.</p>
  </blockquote>