如何实现以下JAVA程序?

[复制链接]
查看11 | 回复2 | 2009-5-6 18:03:06 | 显示全部楼层 |阅读模式
题意如下:
Write a main method to let a user enter student scores,and display the max,min,and average of the score.The input 0 signifies the end of input
我写的代码如下:
package help;
import java.util.*;
public class Help08 {
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList arr=new ArrayList();
double sum=0;
double average=0;
double max=0;
double min=0;
Scanner in=new Scanner(System.in);
while(in.nextDouble()!=0)
{
arr.add(in.nextDouble());
for(int i=0;iarr.get(i))

min=arr.get(i);
}
System.out.println("The max of the scores is: "+max);
System.out.println("The min of the scores is: "+min);
System.out.println("The average of the scores is: "+average);
}

}
}
但好像题意要求的在输入0时结束输入没有作用.请帮忙改一下!

回复

使用道具 举报

千问 | 2009-5-6 18:03:06 | 显示全部楼层
这个是我前几天回答别人的问题。和你的问题大同小异自己改一下就行了。/*以上这段简单代码能实现4个成绩输入,并挑出最高成绩和最低成绩,我想在里面再加入 1.求平均成绩 2.确定每个分数档(每10分为一档,不及格为一档)的人数和百分比*///(为了方便看结果,我把满分设为100分,及格60分)import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class MyDemo {public static void main(String[] ...
回复

使用道具 举报

千问 | 2009-5-6 18:03:06 | 显示全部楼层
这个要连接数据库,我还没学到这,不好意思啊,有空交流交流啊 我新手...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行