title: Exception in thread "main" java.lang.IndexOutOfBoundsException:
body: <p>The program uses methods to:</p>
  
  <ol>
  <li><p>get the numbers used to calculate the average,</p></li>
  <li><p>get the number of lowest numbers to drop before calculating the</p></li>
  <li><p>get the weight, a double greater than 0 and less than or equal to 1,</p></li>
  <li><p>calculate the weighted average of the numbers (except the lowest n numbers) entered by the user, and</p></li>
  <li><p>print the results.</p></li>
  </ol>
  
  <p>The first method should take no arguments and return an array list of doubles.</p>
  
  <p>The second method should take no arguments and return a single integer, the number of the lowest numbers to drop before calculating the average.</p>
  
  <p>The third method should take no arguments and return a double (the weight)</p>
  
  <p>The fourth method should take three arguments: an array list of numbers (the return value of the first method above); an integer (the number of smallest items to drop before calculating the average); and a double (the weight). This method should return a double (the weighted average of all the numbers except the lowest n values).</p>
  
  <p>The fifth method should take four arguments: an array list of numbers (the return value of the first method above); an integer (the number of smallest numbers to drop before calculating the average); a double (the weight); and a double (the weighted average returned from the fourth method above). This method should have no return value.</p>
  
  <p>For example:</p>
  
  <p>If the user gives these numbers for calculating the average:</p>
  
  <p>40 60 80 100 20</p>
  
  <p>and the user gives the number 2 to indicate how many of the lowest values should be dropped before calculating the average, and gives a weight of 0.5, then the program should give as output:</p>
  
  <p>The weighted average of the numbers is 40.0, when using the data 40.0, 60.0, 80.0, 100.0, 20.0, where 0.5 is the weight used, and the average is computed after dropping the lowest 2 values.</p>
  
  <pre><code>import java.util.*;
  import java.lang.*;
  import java.util.ArrayList;
  import java.util.Collections;
  
  
  public class MyClass 
  {
      public static ArrayList&lt;Double&gt; getALInfo() 
      {
          Scanner in=new Scanner(System.in);
          ArrayList&lt;Double&gt; inputs = new ArrayList&lt;&gt;();
          System.out.println("Please enter 5 - 10 integers, Q to quit: ");
  
          String [] tokens = in.nextLine().split("\\s");
  
          for (int i = 0; i &lt; tokens.length; i++)
              inputs.add(Double.parseDouble(tokens[i]));
  
          return inputs;
      }   
  
      public static int getLowestnum() 
      {        
          int lowNum = 0;
          System.out.println("How many of the lowest values should be dropped? ");
          Scanner in = new Scanner(System.in);
          lowNum = in.nextInt();
  
          return lowNum;
  
      }
      public static double weight() 
      {
          Scanner in = new Scanner(System.in);
          System.out.println("Enter the weight: ");
          double weight = in.nextDouble();
  
          return weight;
      }
  
      public static double calculateAvg(ArrayList&lt;Double&gt; inputs,double weight, int lowNum) 
      {
          double sum = 0;
          double average = 0;                
  
          Collections.sort(inputs);
          ArrayList&lt;Double&gt; inputs1 = new ArrayList&lt;Double&gt;(inputs.subList(lowNum, inputs.size()+1));
  
          for (int i = 0; i &lt; inputs1.size(); i++) 
          {
              if (inputs1.get(i) &gt; lowNum) 
              {
                  sum = sum + inputs.get(i);
              }
          }
          sum=weight*sum;
          average = (sum / inputs1.size());
  
         return average;
      }
  
      public static void getAvg(ArrayList&lt;Double&gt; inputs,int n,double weight, double average) 
      {
  
          System.out.println("The weighted average of the numbers is " + average + ", when using the data " + inputs + " where " +weight+ " is the weight used, and the average is computed after dropping the lowest " +n+" values");  
      }
  
      public static void main(String args[]) 
      {
          int lowNum = 0;  
          double average; 
          double weight=0;
          ArrayList&lt;Double&gt; inputs= getALInfo();
          lowNum = getLowestnum();
          weight=weight();
          average = calculateAvg(inputs,weight, lowNum);
          getAvg(inputs, lowNum,weight, average);
      }
  }
  </code></pre>
  
  
  
  <p>The program is running fine util you enter the weight after that it shows an array out of bounds exception error. Can you point out where im going wrong .</p>