java中如何计算百分比之后保留指定…

来源:互联网 发布:今天淘宝网怎么打不开 编辑:程序博客网 时间:2024/06/15 02:52
double passPercent=pass/(double)score.length;
double excellentPercent=excellent/(double)score.length;
//获取格式化对象
NumberFormat nt=NumberFormat.getPercentInstance();
nt.setMinimumFractionDigits(2);
System.out.println("及格率为:"+nt.format(passPercent));
System.out.println("优秀率为:"+nt.format(excellentPercent));
0 0
原创粉丝点击