作者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