public class TinhTrungBinhCong {
public static void main(String[] args) {
System.out.println("Nhập vào số phần tử trong mảng: ");
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
double[] arr = new double[n];
double total = 0;
for(int i=0; i<arr.length; i++){
System.out.print("Nhập vào giá trị cho phần tử thứ "+(i+1)+": ");
arr[i] = scanner.nextDouble();
}
scanner.close();
for(int i=0; i<arr.length; i++){
total = total + arr[i];
}
double average = total / arr.length;
System.out.format("Kết quả là: %.3f", average);
}
}