title: How and where can I place my Bubble sort algorithm in Java
body: <p>I am trying to create a program that will ask the user to input 20 double values. The program will then add the total of all input and compute the average. Then I need to display the sum, average, values less than 5.00 and values greater that the computed average. So far, I am able to do that. However, we were also asked to display all elements in descending order. We were introduced to bubble sorting but I cannot figure out where and how to place it in my current codes because it's affecting the other results. We are only allowed to use BufferedReader for this by the way.</p>
  
  <p>This is the code that I have so far:</p>
  
  <pre><code>import java.io.*;
  public class Prices {
  public static void main(String[]args)throws IOException{
  
      BufferedReader br = new BufferedReader(new InputStreamReader (System.in));
      double [] price = new double [5];
      double sum = 0, ave = 0, temp;
  
      System.out.print("Enter a value that has a decimal point: " );
  
      for(int i=0; i&lt;price.length;i++) 
   //loop for accepting values for the array, adding values and getting the ave of the values
      {
  
          price[i] = Double.parseDouble(br.readLine());//holds the values of the input
  
          sum += price[i];//adds all the input
          ave = sum/5;//divides the computed sum by array size
      }
      // for printing the total sum &amp; ave
      System.out.println("The sum is = "+sum);
      System.out.println("The average is = "+ave);
  
      for(int i=0; i&lt;price.length;i++){//loop for displaying values&lt;5.00 and values&gt;computed ave.    
      if (price[i]&lt;5.00)
      {   
          System.out.println("Values less than 5.00: "+ price[i]);
      }
      if (price[i]&gt;ave)
      {
          System.out.println("Values greater than average: "+ price[i]);
      }
      }  
  }
  }
  </code></pre>