作者a22732 (ψ(‵▽′)ψ)
看板java
標題[問題] 最終成績計算
時間Mon Dec 23 17:07:03 2013
想要以視窗輸入成績的方式
最後跑出來可以有總平均跟標準差
但是目前寫出來的程式卻變成每輸入一筆都會跑出一次平均跟標準差
請問我應該要怎麼改?
平均與標準差部分的程式如下
count = count + 1; // 記數加 1
exam1Ave = exam1Ave / count;
exam2Ave = exam2Ave / count;
exam3Ave = exam3Ave / count;
aveAve = aveAve / count;
System.out.println("=================================================================");
System.out.println("平均數
\t\t"+two.format(exam1Ave)+"\t"+two.format(exam2Ave)+"\t"+two.format(exam3Ave)+
"\t"+"\t"+two.format(aveAve));
// 算每一科的標準差
exam1Sd = Math.sqrt((exam1Sd - count*Math.pow(exam1Ave,2))/count);
exam2Sd = Math.sqrt((exam2Sd - count*Math.pow(exam2Ave,2))/count);
exam3Sd = Math.sqrt((exam3Sd - count*Math.pow(exam3Ave,2))/count);
aveSd = Math.sqrt((aveSd - count*Math.pow(aveAve,2))/count);
System.out.println("標準差
\t\t"+two.format(exam1Sd)+"\t"+two.format(exam2Sd)+"\t"+two.format(exam3Sd)+
"\t" + "\t"+two.format(aveSd));
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 120.125.56.9
1F:推 duck10704:Count=3再印出來 12/23 17:49
3F:→ a22732:才跑出平均那些的 12/23 18:03