title: Sum and Average gives incorrect output
body: <p>I have this code for calculating sum and average, but it gives me wrong calculations. Do you have any idea why?</p>
  
  <pre><code>import java.util.Scanner;
  
  public class SumAndAverage {
     public static void main(String args[]) {
         Scanner input = new Scanner(System.in);
  
         System.out.print("Enter a lower bound then an upper bound:");
  
         double sum = 0;
         double average;
         int lowerbound = input.nextInt();
         int upperbound = input.nextInt();
  
         System.out.println("The upper bound " + upperbound);
  
         for(int number = lowerbound; number &lt;= upperbound; number++) {
             sum += number;
         }
  
         average = sum/upperbound;
         System.out.println("The sum is " +sum);
         System.out.println("The average is " + average);
     }
  }
  </code></pre>