import java.util.*;
class MathTest
{
public static void main(String[] args)
{
show();
}
public static void show()
{
Scanner sc = new Scanner(System.in);
double d = sc.nextDouble();
int i = (int)(d*100); //这里应该如何写能让其先四舍五入后再保留两位小数
sop(i); //例如接收:12.2469,我想输出12.25
double d1 = (double)i/100;
sop("d="+d1);
}
public static void sop(Object obj)
{
System.out.println(obj);
}
} |
|