题目
输入10个整数,输出这10个整数的的平均数,要求输出的平均数保留2位小数
###输入样例:
1 2 3 4 5 6 7 8 9 10
###输出样例:
5.50
代码展示
public class demo07 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double totalCount = 0;
//定义一个大小为10的数组
int[] arr = new int[10];
//输入数据
for (int i = 0; i < arr.length; i++) {
arr[i]=scanner.nextInt();
totalCount+=arr[i];
}
//输出数据
System.out.printf("%.2f",totalCount/arr.length);
}
}