题解 | 求平均年龄
求平均年龄
https://www.nowcoder.com/practice/ca319fdb02714994850cc631d76f5547
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int sum = 0;
for (int i = 0; i < n; i++) {
int number = scanner.nextInt();
sum += number;
}
System.out.printf("%.2f", sum * 1.0 / n);
}
}