import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class newthing {
public static void main(String[] args) throws FileNotFoundException {
File file = new File("D:\\qzq\\temp.txt");
Scanner scan = new Scanner(file);
double total = 0;
scan.useDelimiter("[^0123456789.]+");
int n = 0;
while (scan.hasNext()){
double x = scan.nextDouble();
total += x;
n++;
}
System.out.println("总成绩:"+ total + ",平均成绩:" + total / n);
}
}
Java学习打卡day13
最新推荐文章于 2024-08-07 11:15:21 发布