int m = 500 * 10000; int n = 600; System.out.println(new Float(m / n) / 100 + "%");
<% java.text.DecimalFormat ad = new java.text.DecimalFormat("0.00"); int x = 500; int y = 600; double x1 = (double)x; double y1 = (double)y; double z = 0; z = x1/y1; double z1 = z*100; %> <%=ad.format(z1)+"%" %>
public class Test { public void getText(){ int x=500; int y=600; double z = x/(y*1.0); System.out.println(java.text.DecimalFormat.getInstance().format(z*100)+"%"); } public static void main(String[] args) { new Test().getText(); } }
import java.text.DecimalFormat; public class Test { public static void main(String args[]) { int x=500; int y=600; double result=Double.parseDouble(String.valueOf(x))/Double.parseDouble(String.valueOf(y)); DecimalFormat df=new DecimalFormat("##.00%"); System.out.println(df.format(result)); }}
int n = 600;
System.out.println(new Float(m / n) / 100 + "%");
java.text.DecimalFormat ad = new java.text.DecimalFormat("0.00");
int x = 500;
int y = 600;
double x1 = (double)x;
double y1 = (double)y;
double z = 0;
z = x1/y1;
double z1 = z*100; %>
<%=ad.format(z1)+"%" %>
public void getText(){
int x=500;
int y=600;
double z = x/(y*1.0);
System.out.println(java.text.DecimalFormat.getInstance().format(z*100)+"%");
}
public static void main(String[] args) {
new Test().getText();
}
}
import java.text.DecimalFormat;
public class Test {
public static void main(String args[]) {
int x=500;
int y=600;
double result=Double.parseDouble(String.valueOf(x))/Double.parseDouble(String.valueOf(y));
DecimalFormat df=new DecimalFormat("##.00%");
System.out.println(df.format(result));
}}
System.out.println(df.format(x*1.0/y));
这就是int转double哈~ 再次感谢!!
int i=500;
int y=600;
double num=(double)i*100/y;
DecimalFormat format=new DecimalFormat();
format.setMaximumFractionDigits(2);
String temp=format.format(num)+"%";
System.out.println("=="+temp);
format.setMaximumFractionDigits(2);
System.out.println(format.format(500.0/600));
java.text.NumberFormat nfp = java.text.NumberFormat.getPercentInstance();
nfp.setMaximumFractionDigits(2);
System.out.println(nfp.format(x*1.0 / y));
Dim j As Integer = 600
Dim a As String a = CStr((i / j) * 100)
a = a.Substring(0, 5) & "%"
MsgBox(a)
CSDN升级了啊。回复的字少就、也不行了啊