public static void showTotalScoreAvg() throws IOException{ double sum = 0; BufferedReader in = new BufferedReader(new FileReader(path)); String studentScore; while((studentScore = in.readLine()) != null) { double mathScore = Double.parseDouble(studentScore.split("\t")[2]); double englishScore = Double.parseDouble(studentScore.split("\t")[3]); double computerScore = Double.parseDouble(studentScore.split("\t")[4]); double totalScore = mathScore + englishScore +computerScore; sum = sum + totalScore; count++; if(MinTotalScore > totalScore) { MinTotalScore = totalScore; } if(MaxTotalScore < totalScore) { MaxTotalScore = totalScore; } studentScore = in.readLine(); } double totalScoreAvg = sum/(double)count; System.out.println("总成绩平均分为:"+ totalScoreAvg);in.close(); }
小草1434
动感光波biubiubiubiu
相关分类