scanner exam
System.out.println("以下将计算输入的数字之和,以回车作为下一个数输入,不是数字时结束,开始计算结果");
Scanner scanner = new Scanner(System.in);
System.out.println("请输入数字");
float sum = 0;
int num = 0;
while (scanner.hasNextFloat())
{
float i1 =scanner.nextFloat();
num = num +1;
System.out.println("输入第"+num+"个数字是"+i1);
sum+= i1;
System.out.println("此时总和为:"+sum);
}
System.out.println("输入的"+num+"个数平均值为"+sum/num);