You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
566 B
19 lines
566 B
package w7;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.FileReader;
|
|
import java.io.IOException;
|
|
|
|
public class AverageScoreBefore {
|
|
public static void main(String[] args) throws IOException {
|
|
BufferedReader br = new BufferedReader(new FileReader("scores.txt"));
|
|
String line;
|
|
int sum = 0, count = 0;
|
|
while ((line = br.readLine()) != null) {
|
|
sum += Integer.parseInt(line);
|
|
count++;
|
|
}
|
|
br.close();
|
|
System.out.println("平均分:" + (double) sum / count);
|
|
}
|
|
}
|
|
|