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("總成績(jī)平均分為:"+?totalScoreAvg);in.close();
??????}
使用.split()報(bào)錯(cuò)數(shù)組越界怎么處理?
動(dòng)感光波biubiubiubiu
2018-05-27 12:38:59