2-4
2013-03-17 20:30 郭莹莹1114010807 阅读(146) 评论(0) 编辑 收藏 举报import java.util.*; public class Example2_4 { public static void main(String arg[]){ Scanner reader=new Scanner(System.in); double sum=0; int m=0; while(reader.hasNextDouble()){ double x=reader.nextDouble(); m=m+1; sum=sum+x; } System.out.printf("%d个数的和为%f\n",m,sum); System.out.printf("%d个数的平均值是%f\n",m,sum/m); } }