Java中,用户随机输入10个数,求平均值。怎么编程呢?
答案:1 悬赏:50 手机版
解决时间 2021-03-26 14:31
- 提问者网友:浩歌待明月
- 2021-03-26 05:32
Java中,用户随机输入10个数,求平均值。怎么编程呢?
最佳答案
- 五星知识达人网友:拾荒鲤
- 2021-03-26 05:40
public static void main(String [] args) {
Scanner sc = new Scanner(System.in);
int count =1;
int sum = 0;
int avg = 0;
while(count<11){
sum +=sc.nextInt();
count++;
}
//平均值
avg = sum/10;
}追问貌似不能输入分数
Scanner sc = new Scanner(System.in);
int count =1;
int sum = 0;
int avg = 0;
while(count<11){
sum +=sc.nextInt();
count++;
}
//平均值
avg = sum/10;
}追问貌似不能输入分数
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯