题意如下:
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);
}