package com.bowenxu.scanner;import java.util.Scanner;publicclassDemo04{publicstaticvoidmain(String[] args){//scanner的一些常见应用
Scanner scanner =newScanner(System.in);int i =0;double sum =0.0;
System.out.println("请输入一个数字");while(scanner.hasNextDouble()){
System.out.println("请输入一个数字");
sum += scanner.nextDouble();
i++;
System.out.println("已经输入了"+ i +"个数字,数字的和sum="+ sum);}
System.out.println("最终输入了"+ i +"个数字,数字的和sum="+ sum +"平均数是:"+(sum/i));
scanner.close();}}