Would you please tell me why my output is always 0.0 ? i want my program to print the sum of the values that are less than the average of all of the values generated .
import java.util.*; public class Test { public static void main(String[] args) { double[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; double result = sumLessThanAverage(numbers); System.out.println(result); } public static double sumLessThanAverage(double[] a) { int sum = 0; int less = 0; for (int i = 0; i < a.length-1; i++) { sum += a[i]; double crazy = sum / a.length; if (i < crazy) less += i; } return (double) less; } }