int a=155;
int b=55;
System.out.println("**********************");
double c=(double)(Math.round(a/b*100)/100.00);//這樣仍是不能解決商保持兩位小數
System.out.println(c);
System.out.println("----------------------");
System.out.println(a/b);
System.out.println((float)a/b);
System.out.println(a/(float)b);
System.out.println((float)a/(float)b);
DecimalFormat df = new DecimalFormat("0.00");//格式化小數,不足的補0
String num = df.format(a/b);//返回的是String類型的
System.out.println(num);
System.out.println(df.format((float)a/b));
System.out.println("----------------------");
orm