java标准百分比

  

import java.text.NumberFormat;

public class 百分比 {
public static void main(String[] args) {
int completed=30;
int total=541;
double percentage=((double) completed/(double) total)*100;
NumberFormat numberFormat=NumberFormat.getPercentInstance();
numberFormat.setMinimumFractionDigits(2);
String result=numberFormat.format(((double)completed)/((double)total));
System.out.println(result);
}
}
posted @ 2019-07-02 14:59  1456710017  阅读(4265)  评论(0编辑  收藏  举报